Francois,

I agree with your assesment of the extra keystroke.  I tried the " _"
option for awhile and found it to be a little less ideal.  Hence this
option is turned off by default in my ess-smart-underscore.el package.
However, the underscore is guessed by context.  In my redifnition of
ess-smart-underscore, the following documentation describes the behavior

Smart "_" key: insert `ess-S-assign', unless:
  1. in string/comment
  2. after a $ (like d$one_two) (toggle with `ess-S-underscore-after-$')
  3. when the underscore is part of a variable definition previously
defined.
     (toggle with `ess-S-underscore-after-defined')
  4. when the underscore is after a \"=\" or \"<-\" on the same line.
     (toggle with `ess-S-underscore-after-<-or-=')
  5. inside a parenthetical statement () or [].
     (toggle with `ess-S-underscore-when-inside-paren')
  6. At the beginning of a line.
  7. In a variable that contains underscores already (for example foo_a)
     (toggle with `ess-S-underscore-when-variable-contains-underscores')
  8. The preceding character is not a tab/space
     (toggle with `ess-S-underscore-when-last-character-is-a-space'.  Not
enabled by default.)


An exception to #4 is in the following situation:

a <- b |

pressing an underscore here would produce

a <- b <-

However when in the following situation

a <- b|

pressing an underscore would produce

a <- b_

This behavior can be toggled by `ess-S-space-underscore-is-assignment'

If the underscore key is pressed a second time, the assignment
operator is removed and replaced by the underscore.  `ess-S-assign',
typically \" <- \", can be customized.  In ESS modes other than R/S,
an underscore is always inserted.

I find this behaviour better than the traditional "_" behavior.

Matt.
On Mon, Apr 9, 2012 at 4:45 PM, Francois Pepin <
francois.pepin@sequentainc.com> wrote:

> Hi Matt,
>
> The main problem I see with that suggestion is that it requires an extra
> keystroke where none was required before.
>
> It's not a big deal, but the reason why I like the current default is that
> it saves me keystroke and brain power. For me, that wouldn't be much better
> than just typing <- manually (which I need to do anyway when I'm using R
> without ESS).
>
> François
>
>
> On Apr 9, 2012, at 13:26 , Matthew Fidler wrote:
>
> > Sorry; I'm a little late, but my opinion is to make the underscore
> > smarter.
> >
> >
> https://github.com/mlf176f2/ess-smart-underscore.el/blob/master/ess-smart-underscore.el
> >
> > Instead of using a space after the underscore, a space before the
> > underscore could be used for assignment.  For instance
> >
> > foo _
> >
> > would produce
> >
> > foo <-
> >
> > Where as
> >
> > foo_ _
> >
> > would produce
> >
> > foo_ <-
> >
> > could produce foo <-.  This should not snag any legal identifiers.
> >
> > This and other cases are taken care of by my smarter underscore key.
> >
> >
> >
> > Matt.
> >
> > On Mon, Apr 9, 2012 at 10:11 AM, Jack Tanner <ihok@hotmail.com> wrote:
> >
> >> Following up on whether to leave the underscore situation
> >> unchanged, I tallied up the mailing list responses (bottom of
> >> this message). Please pardon me if I misinterpreted anyone's
> >> thoughts.
> >>
> >> People seemed to rally around the compromise to create a new
> >> option to bind "<-" insertion to another key. This would satisfy
> >> my original request with respect to editing R buffers, but it
> >> would not help with editing BUGS / JAGS code, and it would not
> >> help ESS novices. If I could rebind smart-underscore and if it
> >> could be disabled for BUGS / JAGS altogether, that would help me,
> >> at least.
> >>
> >> Parenthetically, I agree that "<-" is the preferred style of
> >> writing assignment in R, and I use it in my own code. But I
> >> disagree that smart-underscore is a good way of teaching that.
> >>
> >> Henning Redestig points out that pasting code containing true
> >> underscores into an ESS R buffer with smart-underscore enabled
> >> will mess up the code. That seems like a serious bug, but it
> >> could perhaps be decoupled from this issue. Henning suggests to
> >> activate smart-underscore only if an underscore is followed by a
> >> space. This change would trigger the pasting bug less often than
> >> the status quo, but it will still snag legal identifiers such
> >> as "foo_".
> >>
> >> Here's my tally of the posts on this. Folks that seem to think
> >> that the status quo is problematic in some way:
> >>
> >> Vitalie Spinu
> >> Henning Redestig
> >> Chris Evans
> >> Jack Tanner
> >>
> >> Folks that are OK with the status quo, but would accept a new
> >> option to bind "<-" insertion to some other key:
> >>
> >> Rainer Krug
> >> Richard M. Heiberger
> >> Joshua Wiley
> >> Gerald Jean
> >>
> >> Folks that would rather see no changes:
> >>
> >> Brendan Halpin
> >> Rodney Sparapani
> >> Tim Hesterberg
> >> Martin Maechler
> >>
> >> ______________________________________________
> >> 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]]

