[ESS] Yet another indentation question: indentation after parenthese

Vitalie Spinu spinuvit at gmail.com
Fri Dec 16 14:49:45 CET 2011


Mathieu Basille <basille at ase-research.org> writes:

> Dear Vitalie,
>
> Thanks for you comment. My first message was not perfectly clear... Your
> example with 'foo' is misleading, since foo is exactly 3 character long.
> Take this silly example instead:
>
> foo <- function(aaaaaaaaaa = 1, bbbbbbbbbb = 2, cccccccccc = 3,
>                 dddddddddd = 4, eeeeeeeeee = 5)
> {
>     return(data.frame(aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd,
>                       eeeeeeeeee))
> }
>
> The new line formatted by ESS starts just after the opening parenthesis.
> If I save the file in bla.R and source it with 'keep.source = FALSE' to
> use the R parser, here is what I get:
>
>> options(keep.source = FALSE)
>> source("bla.R")
>> foo
> function (aaaaaaaaaa = 1, bbbbbbbbbb = 2, cccccccccc = 3, dddddddddd = 4,
>     eeeeeeeeee = 5)
> {
>     return(data.frame(aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd,
>         eeeeeeeeee))
> }

Ok, I got it. Check the keep.source option:

options("keep.source")

If it's FALSE I am getting your output and this is the problem of R, ESS
cannot easily help you here. In my setup  keep.source is T, so I am
getting everything ok.

HTH,
Vitalie.

>
> That is, the new line simply adds 4 spaces from the left margin (not
> from the opening parenthesis, which, I agree, would make no sense) and
> do not start after the opening parenthesis. There is two reasons I would
> like to have this behaviour with ESS: 1) first, it would not change the
> formatting of my functions if I source them with the R parser, and 2) it
> can be a real source of nightmares when there are many nested
> parentheses, and everything gets pushed to the right.
>
> All the best,
> Mathieu.
>
> Le 16/12/2011 06:32, Vitalie Spinu a écrit :
>> Mathieu Basille <basille at ase-research.org> writes:
>> 
>>> Dear ESS gurus,
>>>
>>> I feel like I'm really missing something... I searched heavily on the net, in
>>> the ESS manual, on this list, without finding what I'm looking
> for. Basically,
>>> when I try to indent some code (with M-C-q), if a line break occurs in the
>>> middle of parentheses or brackets, the next line will be indented to the
> first
>>> character after the parenthesis. How can I get rid of this, and get a
> normal' 4
>>> spaces indentation? (this is, I think, the behaviour of the R parser)
>>>
>> 
>> I am not really understanding that. You mean that
>> 
>> 
>>     foo(arg1 = 1, arg2 = 2,
>>         arg3 = 3)
>> 
>> Is not what you want? and you would like:
>> 
>> 
>>     foo(arg1 = 1, arg2 = 2,
>>             arg3 = 3)
>> 
>> instead?
>> 
>> Doesn't make sense to me.
>> 
>> Vitalie.



More information about the ESS-help mailing list