Yes, having the ability to quickly (and well) reformat source code received
from others is something I would very much like.  Just a supporting email
that this is worth spending >0 time on.

Best,
Kasper


On Mon, Jun 17, 2013 at 10:49 PM, Martin Maechler <
maechler@stat.math.ethz.ch> wrote:

> On Mon, Jun 17, 2013 at 7:14 PM, Yihui Xie <xie@yihui.name> wrote:
>
> > To replace = with <-, I think regular expressions are less reliable
> > than codetools.
>
>
> Definitely!
> Thank Yihue!
>
> Note though that the ESS function is much older than the codetools
> package....
>
> You may want to take a look at the function
> > replace_assignment() here:
> > https://github.com/yihui/formatR/blob/master/R/utils.R (credit goes to
> > Kohske Takahashi: https://github.com/yihui/formatR/pull/20)
> >
>
> I quickly did and it looks like a very good idea.  I was not aware how nice
> and short such a function could become,
> using codetools appropriately.
> Very nice!
>
> This seems well worth to use for ESS.... but I have few more important
> things to do first..
> Definitely will look at it in more detail (if nobody beats me to it)!
> Martin
>
> >
> > Regards,
> > Yihui
> > --
> > Yihui Xie <xieyihui@gmail.com>
> > Phone: 206-667-4385 Web: http://yihui.name
> > Fred Hutchinson Cancer Research Center, Seattle
> >
> >
> > On Sat, Jun 15, 2013 at 1:00 AM, Martin Maechler
> > <maechler@stat.math.ethz.ch> wrote:
> > >
> > >     > On Fri, Jun 14, 2013 at 3:06 PM, Andreas Leha <
> > >     > andreas.leha@med.uni-goettingen.de> wrote:
> > >
> > >     >> Rainer M Krug <Rainer@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
> >
> > ______________________________________________
> > ESS-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>

	[[alternative HTML version deleted]]

