Here is an example of how to format magrittr chains with ESS. Those interested will also be happy to learn of ess-R-fl-keyword:%op%
and ess-%op%-face
.
For example, to get the an indent after only the first statement.
(add-to-list 'ess-style-alist
'(my-style
(ess-indent-level . 4)
(ess-first-continued-statement-offset . 2)
(ess-continued-statement-offset . 0)
(ess-brace-offset . -4)
(ess-expression-offset . 4)
(ess-else-offset . 0)
(ess-close-brace-offset . 0)
(ess-brace-imaginary-offset . 0)
(ess-continued-brace-offset . 0)
(ess-arg-function-offset . 4)
(ess-arg-function-offset-new-line . '(4))
))
(setq ess-default-style 'my-style)
Thank you Mr. Vitalie Spinu.
ADDENDUM
How I did it:
(setq gcr/ess-style
(copy-alist
(assoc 'RRR ess-style-alist)))
(setf (nth 0 gcr/ess-style) 'GCR)
(setf (cdr
(assoc 'ess-continued-statement-offset
(cdr gcr/ess-style)))
0)
(add-to-list 'ess-style-alist gcr/ess-style)
(setq ess-default-style 'GCR)
Addendum: 2015-08-12
The latest version of ESS includes a RRR
style.
It formats Magrittr chains as expected by default with ess-first-continued-statement-offset
.
Grant Rettke: How to Format Magrittr Chains with ESS http://t.co/PQ3CWEdVtI
I don’t suppose you also found a way to make comments which match the conventions of the R community, rather than that of Emacs lisp? Auto-indenting # right is a minor annoyance for both parties when trying to collaborate with people developing R outside of Emacs.
WDKRNLS:
Just added how I set it up to the post.