[ESS] reformat source code
Martin Maechler
maechler at stat.math.ethz.ch
Sat Jun 15 10:00:04 CEST 2013
>>>>> Kasper Daniel Hansen <kasperdanielhansen at gmail.com>
>>>>> on Fri, 14 Jun 2013 22:59:09 +0200 writes:
> Thanks Rainer and Andreas I knew there was something along
> these lines; but I could not find it with a cursory
> (admittedly) look in the manual.
yeah.. we know, the manual is far from perfect, and we are glad
for patches..
(read on!)
> Best, Kasper
> On Fri, Jun 14, 2013 at 3:06 PM, Andreas Leha <
> andreas.leha at med.uni-goettingen.de> wrote:
>> Rainer M Krug <Rainer at krugs.de> writes:
>>
>> >>
>> >> Is there an easy way to replace = assignments with <-?
>> >
>> > Other then M-% and to decide fir each, I don't think
>> so?
>> >
>>
>> There is ess-fix-EQ-assign.
>>
>> There are also ess-MM-fix-src and ess-fix-miscellaneous
>> which might be of interest here.
>> Best, Andreas
Indeed, thank you, Andreas!
All of three of them have emerged historically, mostly tended to
by myself. Notably, 'ess-MM-fix-src, as the name still
alludes to, have been my own "code fixups" which after years of
successful use had been added to ESS where I've kept "MM" as
some changes may be a matter of taste only.
OTOH, the ess-fix-miscellaneous -- BTW, much easier to find:
M-x ess-fix [TAB] --
originally have been uniformly agreed on improvements, notably replacing
the bad use of 'T' and 'F' by the correct use of 'TRUE' and 'FALSE'
{don't start a flame war here if you disagree.. this has been part of
R and R-core's design since ever, even if bad IDEs do colorize
T and F as if they were the same as TRUE and FALSE}.
All of these fixups are not perfect, notably can have both false
positives and negatives.
The ess-fix-EQ-assign, i.e., substituting
"=" by "<-" (including surrounding whitespace!)
replacement could be made perfect in principle, if ESS would use
R's parser and R itself to analyze which of the "=" are
assignments and which mean setting of function arguments.
Currently it's not at all perfect as the doc string and the
comments (all functions are in ess/lisp/ess-s-l.el ) show.
IMO, the fact that this is not easy, is exactly a *proof* why
using '<-' and '=' diligently in your own code adds much to code
legibility both for yourself (notably when re-reading code you
wrote a while ago!) and for other readers of your code.
Also, what these functions do not do much is syntatic
indentation (*after* having fixed up some the '# ..' comments),
and I have always wondered if we should not try to do so.
In summary, a complete overhaul / redesign of these code fixups
would actually be desirable.
If some of you feels somewhat comfortable with emacs lisp and
is willing to put in some effort, I'd be happy to consider
collaboration here.
Martin
More information about the ESS-help
mailing list