[ESS] disabling C-c h bound to ess-handy-commands

Vitalie Spinu spinuvit at gmail.com
Tue Oct 9 20:38:16 CEST 2012


  >> Martin Maechler <maechler at stat.math.ethz.ch>
  >> on Tue, 9 Oct 2012 19:50:37 +0200 wrote:

[...]

  >> Here is a constructive proposal:
  >> 
  >> C-c C-e ess-extra-map (includes roxygen, which already hands on it)
  >> C-c C-d ess-doc-map (ess-dump-object-into-edit-buffer is moved onto C-c C-e C-e)
  >> C-c C-d ess-dev-map (ess-execute-in-tb is moved on C-c C-e C-t)
  >> C-c C-a ess-handy-commands
  >> 
  >> Remove C-c C-y (C-c C-z does the job and is faster)
  >> Remove C-c C-k (C-c C-s should be enough and is faster)
  >> 
  >> ;; Not very sure about this one:
  >> Remove C-c C-f (C-c C-c and C-M-x do that anyways)
  >> 
  >> C-c C-f is a very handy key and can be assigned to something very nice
  >> (like tooltips on object structure http://www.sigmafield.org/comment/10> which we are planing to move into ESS soon).

  > I like all your proposals but the last.
  > C-c C-f  has -- for a very long time -- been one of the most important
  > eval commands.
  > It's ok to *plan* to *eventually*  remove it,
  > but as with important changes in R, this *definitely* needs a
  > deprecation period of at least one year.   Many of us good S and R
  > programmers  write functions "all the time", and have had ingrained
  > C-c C-f  long before  C-c C-c (or even C-M-x) came along at all.
  > The deprecation in the first phase would mean to have it work as
  > previously with an additional

Sure, but would be good to free C-c C-d and C-c C-t in the next release;
ess-dump-object-into-edit-buffer (aka edit) will move to C-c C-e C-e
with a very similar positioning, so not a big deal. And we really need
to put dev map on C-c C-t to free user level C-c d key. 


It occurred to me today that it might be good to make C-c C-c and C-M-x
not to evaluate function but a complete syntactic block. For example

out <- {
  a <- 23

  b <- 2*a

  b^2
}


If the cursor is on line "b", currently C-c C-c sends only the line "b
<- 2*a", which is most likely not what is needed.

Having empty lines in code is often a good style.  So I propose to make
C-c C-c to try to evaluate paragraph or a complete syntactic block at
level 0, whichever is maximal. This way C-c C-p and C-c C-f are not
anymore redundant with C-c C-c.

This also nicely treat nested functions. For example C-c C-c currently
evaluates wrong pieces in the following cases (with the cursor indicated
by "|"):

sapply(X, function(el) ... | ... )

foo <- function(...){
    local <- function(...){
        ... | ...
    }
}

Blockwise evaluation doesn't have this problem.

Blocks also generalizes nicely to other languages, whereas
function/defun might not.

    Vitalie



More information about the ESS-help mailing list