[ESS] edit.vignette

Rodney Sparapani rsparapa at mcw.edu
Thu Nov 6 21:03:17 CET 2008

Erik Iverson wrote:
> 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.
> Example:
> library(grid)
> edit(vignette("grid"))
> 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 
> https://stat.ethz.ch/pipermail/ess-bugs/2006q2/000292.html
> "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.
> Thanks,
> Erik Iverson

Hi Erik:

It works here with XEmacs and gnuclient.  The only differences are that 
I have to press C-g after edit..., otherwise, I never see the vignette 

Also, when I am evaluating, the commands never seem to be echoed in
the *R* buffer.  That is different from what I see with GNU Emacs.
Oh well, you get the point.

Rodney Sparapani      Center for Patient Care & Outcomes Research (PCOR)
Sr. Biostatistician              http://www.mcw.edu/pcor
4 wheels good, 2 wheels better!  Medical College of Wisconsin (MCW)
WWLD?:  What Would Lombardi Do?  Milwaukee, WI, USA

More information about the ESS-help mailing list