[ESS] Yet another indentation question: indentation after parenthese

Mathieu Basille basille at ase-research.org
Fri Dec 16 14:32:52 CET 2011


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))
}

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.

-- 

~$ whoami
Mathieu Basille, Post-Doc

~$ locate
Laboratoire d'Écologie Comportementale et de Conservation de la Faune
+ Centre d'Étude de la Forêt
Département de Biologie
Université Laval, Québec

~$ info
http://ase-research.org/basille

~$ fortune
``If you can't win by reason, go for volume.''
Calvin, by Bill Watterson.



More information about the ESS-help mailing list