[ESS] 2 things I wish ESS would do

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Wed Apr 30 19:31:56 CEST 2008


Dear Paul,
thanks for your comments.  Here are my views, perhaps others in
ess-core will chip in with theirs:

 > 1. I asked for this before, some of you said it was unnecessary for
 > you.  OK.  I still  wish the command history would interleave commands
 > sent from the ESS script file and commands typed at the command
 > prompt.  Since some of you don't want that, I don't want that imposed
 > on everybody.  But can it please be an option?  In the past, some
 > other users said they would like this, but we were shouted down by
 > others who said "just go read your script file if you want to see what
 > you did." But that really does not help.

If there is an easy way of stashing commands into Emacs' history, then
I see no reason why it shouldn't be done, and made an option (default
off).  I'm not sure if anyone has investigated it.  And presumably it
gets complicated, what if I eval a whole region of several lines at
once -- should they all go in as one history item(if they can),  or
broken up into lines?  Or should this be available only for the ESS
commands that send one line at a time to an *R* buffer?

 > 2. Can you make it easier to transfer commands that work from the *R*
 > window back to the script file "blob.R" ?  Once we do hack our way to
 > success in the *R* file, we want to get those commands back and save
 > them.  At the current time, the only way I can find is to highlight
 > the whole section of the *R* buffer, copy it over to "blob.R" and then
 > delete all the lines that don't start with > and edit the rest.

The transcript editing code might be useful here.  e.g. given some
region of *R* output like

> x <- rnorm(2)
> x + 3
[1] 3.091824 4.764668
> x - 1
[1] -0.9081763  0.7646682
> 
if I copy & paste that into a buffer called "foo.Rt" and then make the
buffer writeable (C-x C-q) and then do C-c C-w
(ess-transcript-clean-region) on the whole buffer, I get:

x <- rnorm(2)
x + 3
x - 1

It should be straightforward to write a defun that takes a marked
region in a *R* buffer, copies it to some temp buffer (e.g. called foo.Rt)
and then runs ess-transcript-clean-region.

However, where would you then want the contents of foo.Rt copied?  In
your case, you would say blob.R, but what if the *R* process is being
used by several .R files [at least I often associate one *R* process
with several buffers].  Some heuristic could be used, e.g. stick it at
point in the most recent .R buffer associated with that process.

would that work for you?

Stephen




More information about the ESS-help mailing list