[ESS] proposal re: underscore

Henning Redestig henning.red at googlemail.com
Sat Apr 7 12:30:11 CEST 2012


2012/4/7 Martin Maechler <maechler at stat.math.ethz.ch>:
> Indeed!  ESS should help novices and others as much as possible to
> *not* start doing "the wrong thing" and use "=" for assignment in
> their R code.

I must say I have also grown very used to the smart underscore and use
it all the time. Unfortunately, one case where it always bites me is
when I paste things into a terminal (from windows clip-board to
terminal by right-click in putty window) all the underscores get
garbled to <- i.e., geom_bar becomes geom <- bar. Detecting difference
between pasting and manual input in this case is probably not possible
(?). My suggestion would be to have conversion to <- only triggered
after typing a space after variable name; geom[_ becomes _]bar and
foo[space][_ becomes <-]. That way underscore would behave as expected
(i.e. produce _) when you may want to type an underscore but <- when
you probably don't want an underscore anyway.

but perhaps the pasting issue is only my headache.

>
> Below we learn that StatET uses  C-x =   and we have Rstudio  using
> "<Alt> -" which is
>  "M--" in Emacs notation.
> The problem with both of these is that are already in "basic use" as
> global emacs keys,
> and the first one even uses 3 keypresses ... too much for most users
> to prevent them from doing "the wrong thing".
>
> What we *should* try is to help novices (and others) detect the fact,
> that you can get a "_" if you need by simply pressing it twice.
> Should we display a message (in the mini buffer) whenever "_" is
> producing a " <- "
> ?  {it's not quite trivial to implement strictly: the message should
> only be produced in the case where the (ess-smart-underscore) was
> produced by "_", not by other means (or keys).
>
> Martin
>
>>
>>>Premise: the smart-underscore behavior in ESS is problematic because
>>>
>>>1) it's inconsistent across modes, as described in my post a couple of weeks ago
>>>and repeated below for convenience
>>>
>>>2) it's confusing to novices, as evidenced by the fact that it's a FAQ
>>>
>>>3) it will be even more confusing to novices over time, because underscore as
>>>assignment operator was phased out in R a long time ago
>>>
>>>4) it requires two keystrokes of underscore to get an actual underscore
>>>
>>>Proposal: ESS should emulate another R editor on this point, namely StatET. The
>>>behavior is as follows:
>>>
>>>1) typing = gets you =
>>>
>>>2) typing _ gets you _
>>>
>>>3) typing <- gets you <-
>>>
>>>4) (this is the magic one) typing Ctrl+= gets you <-
>>>
>>>The main argument 'pro' is that 1-3 are not at all confusing to novices, and 4
>>>is a discoverable feature, i.e., a reward for advanced users. Additionally, this
>>>would be consistent across S, R, BUGS, and JAGS, and would not violate their
>>>syntax, unlike the current behavior (explained in my older note, below).
>>>
>>>The current smart-underscore could be retained as-is for those who want it but
>>>turned off by default in future versions.
>>>
>>>-- my older email, repeated for reference --
>>>
>>>1. In ESS[BUGS] mode, underscore is bound to ess-bugs-hot-arrow, which is
>>>definitely wrong, because it doesn't let me create variables like foo_bar.
>>>
>>>2. I'd like it if I could use smart-underscore as in ESS[S] mode, but if I do
>>>
>>>(define-key ess-bugs-mode-map (kbd "_") 'ess-smart-underscore)
>>>
>>>then there's no smart-underscore behavior, just a plain underscore.
>>
>> ______________________________________________
>> ESS-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help
>>
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



-- 
/Henning



More information about the ESS-help mailing list