[ESS] edit.vignette

Erik Iverson iverson at biostat.wisc.edu
Thu Nov 6 19:22:54 CET 2008

Hello all -

I am using ESS, version 5.3.8, latest R.  I want to "edit" a vignette, 
i.e., see the R code associated with the vignette, and be able to send 
that code to my *R* buffer.



As my editor is emacsclient, this brings up the correct .R file in a 
buffer, and my *R* buffer shows "Waiting for Emacs".  Per a thread on 
this list, found at 

"edit(vignette(...)) works fine for me, the only thing that may be hard
to find out for users is that you have to press C-c C-c in the R
buffer to get back to the prompt (by default R waits for the file to
be closed), but once you have done that you can edit the vignette
code, send it line by line to R etc."

This sounds exactly like what I want.  The problem is, I switch over to 
the *R* buffer, do C-c C-c, and the buffer with the vignette with R code 
in is killed!  So I'm not able to replicate the behavior of the 
preceding paragraph.

Can anyone get that to work using the above process?

I did get what I want working by defining a function myemacs, as

myemacs <- function(file = "" , title = "") {
   system(paste(getOption("editor"), "-n", file))

and then calling edit.vignette like this:

edit(vignette("grid"), editor = myemacs)

This works because edit.vignette calls file.edit, which accepts a 
function name for the "editor" argument, but this solution relies on 
internal, undocumented behavior.

The key is the "-n" argument to emacsclient, which doesn't wait for the 
emacs server to return, thus the .R file is open, and the *R* buffer is 
waiting for input.

Erik Iverson

More information about the ESS-help mailing list