[ESS] Yet another indentation question: indentation after parenthese
rsparapa at mcw.edu
Fri Dec 16 20:54:25 CET 2011
Mathieu Basille wrote:
> Alright, I think I start to understand the problem, and what seemed easy to
> me might not be possible. I thought that taking parentheses into account
> would be easier than ignoring them, thus my question!
> I will stick to 'C++' or 'RRR' styles and manually adjust them when needed
> (using e.g. 'source' with 'options(keep.source = FALSE)'). This makes,
> however, the use of 'auto-fill-mode' virtually impossible to me, because
> such statements:
> toto <- someFunction(arg1 = bli, arg2 = bla, arg3 = blo, arg2 = c("a",
> "bla", c(1, 2, 3, 4), "blo", "blu", "bli"))
> will render awfully with a column width of 70. I can live with this (well,
> I did for many years now!), I just hoped that there was a way to follow
> what R uses internally to format R code. I find it a pity that such a great
> editor like Emacs (which is, by far, the best tool I tried to edit R/Rnw
> scripts, with the result that I couldn't work without it now) can't
> reproduce R behaviour.
> Vitalie and Richard, many thanks go to you for your efforts to 1)
> understand (!) and 2) trying to find a solution to my little problems!
> All the best,
Making it into a style might be a challenge. Mode grammar/syntax is not
much fun to play with. Look at the definition of parentheses to see if
they are a word or punctuation. Otherwise, you could probably create an
elisp function that calls R to replace a function with its re-formmatted
equivalent. ESS has several functions that work like that. For
example, take a look at ess-ebcdic-to-ascii-search-and-replace which
replaces EBCDIC passages in the buffer with their ASCII equivalents.
You might also be able to use ESS primitives that find the function
definitions and repeatedly replace them (just like you can search and
replace multiple EBCDIC blurbs in one go).
More information about the ESS-help