[ESS] indentation styles

Vitalie Spinu spinuvit at gmail.com
Fri Mar 30 20:03:12 CEST 2012


>>>> Jack Tanner <ihok at hotmail.com>
>>>> on Fri, 30 Mar 2012 15:22:19 +0000 wrote:

  > Vitalie Spinu <spinuvit <at> gmail.com> writes:
  >>
  >> This has been done and will be available in new version of ESS.

  > Wow, that was pretty fast.

Well, it has been implemented for some time as a result of this request
https://github.com/emacs-ess/ESS/pull/1, which wanted exactly the same
thing as you.

  > I played around with it, and it doesn't quite do what
  > I want:
  > barbarbarbar <- foofoofoofoo(arfarfarfarfarf(
  >                               vroovroovroo=3,
  >                               blahblahblah=5
  >                               )
  >                              )

Indeed, it indents with respect to the previous sexp (arfarfarfarfarf in
your case). You can do something like:

barbarbarbar <-
    foofoofoofoo(arfarfarfarfarf(
                   vroovroovroo=3,
                   blahblahblah=5
                 ))


After looking again into the code I realized that it's actually quite
easy to implement what you guys want. So easy that I've just done it.

Now the doc of ess-arg-function-offset-new-line says:


    If nil, the statements are indented at open-parenthesis following foo:

      a <- some.function(other.function(
                                        arg1,
                                        arg2)

    If a list of the form '(N) where N is a number, the statements
    are indented at the previous line indentation + N characters:

      a <- some.function(other.function(
         arg1,
         arg2)


    If a number N, the statement are alligned at the beggining of
    function call + N characters:

      a <- some.function(other.function(
                           arg1,
                           arg2)


    For inner function arguments the behavior is unchanged:

So set ess-arg-function-offset-new-line to '(4), and you will get it.

Best,
Vitalie.



More information about the ESS-help mailing list