yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
255 stars 52 forks source link

Suggestion: option to permit keeping line-breaks inside function calls #40

Closed mike-lawrence closed 10 years ago

mike-lawrence commented 10 years ago

I often find it useful to have my code as:

out = f(
    arg1 = 1
    , arg2 = 2
)

This is particularly useful for functions with lots of arguments. Any chance you could include an option to permit this format?

jrowen commented 10 years ago

To add to this suggestion, it would also be useful to support commenting out function (or list) arguments. The examples below currently generate an error, Error in base::parse(text = code, srcfile = NULL).

out = f(
    arg1 = 1
    #, arg2 = 2
    , arg3 = 3
)

or

out = f(
  arg1 = 1,
  #arg2 = 2,
  arg3 = 3
)
yihui commented 10 years ago

@mike-lawrence Sorry, that is beyond my capability. I can only do whatever deparse() allows me to do.

@jrowen Unfortunately that is by design, and documented: https://github.com/yihui/formatR/wiki#6-further-notes Perhaps you won't believe it, but it is a difficult problem for me. It has been there from day one, and you are not the only one who suggested it.