[ESS-bugs] Variable name affects indentation
Martin Maechler
maechler at stat.math.ethz.ch
Sat Aug 18 11:13:51 CEST 2012
It's clearly from (ess-calculate-indent ... ) in ess-mode.el
and its very old code that special cases "expression"....
Code that goes back to when Tony took started using the revision control system.
The code in question is
;; modified by shiba at isac 7.3.1992
(cond ((and (numberp ess-expression-offset)
(re-search-backward "[ \t]*expression[ \t]*" bol t))
;; This regexp match every "expression".
;; modified by shiba
;;(forward-sexp -1)
(beginning-of-line)
(skip-chars-forward " \t")
;; End
(+ (current-column) ess-expression-offset))
and it is clearly why it leads to the wrong indentation here.
The corresponding indentation variable is documented in ess-utils.el :
(defvar ess-expression-offset 4
"Extra indent for internal substatements of `expression' that specified
in `obj <- expression(...)' form.
If not number, the statements are indented at open-parenthesis following
`expression'.")
and that I think explains the intent, i.e., what 'shiba' *did* solve
in March 1992,
by replacing the (forward-sexp -1)
by the the two (beginning-of-line) (skip-chars-forward " \t")
Tony, would you remember more ?
It seems it's "easy" to solve if
"[ \t]*expression[ \t]*" is replaced by a smarter one.
I'll try a bit.
Martin
On Sat, Aug 18, 2012 at 10:51 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
> Dear Hendrik,
>
> On Wed, Aug 15, 2012 at 3:15 AM, Hendrik Weisser
> <weisser at imsb.biol.ethz.ch> wrote:
>> Hi!
>>
>> Working with protein expression data, I've noticed that using the variable
>> name "expression" breaks the indentation in my R code:
>>
>> What I expect to see:
>> expression <- somefunction(longarg1,
>> longarg2)
>>
>> What happens:
>> expression <- somefunction(longarg1,
>> longarg2)
>>
>> I.e. the indentation at the level of the opening brackets after a line break
>> doesn't work as usual (same for square brackets).
>
> I can confirm. This is a buglet.
>
>> I assume this has
>> something to do with "expression" being a pre-defined function in R.
>
> Well, not really directly: if I use "data.frame" or "list" instead
> of "expression",
> the indentation is correct.
>
>>
>> It's just a little annoyance, but maybe it could be fixed nonetheless.
>
> Yes, I hope we'll find a cure before the next release of ESS.
> Martin
>
>>
>> Best regards
>>
>> Hendrik Weisser
>>
>> _______________________________________________
>> ESS-bugs ESS-bugs at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/ess-bugs
>>
>> _______________________________________________
>> ESS-core list: https://stat.ethz.ch/mailman/listinfo/ess-core
>>
More information about the ESS-bugs
mailing list