[ESS] new user questions: appending to transcripts and buffer management
Charles C. Berry
cberry at tajo.ucsd.edu
Sun Aug 15 20:22:23 CEST 2010
On Sat, 14 Aug 2010, Andrei Jirnyi wrote:
> What I think would be quite useful to have is a command to select a block of
> text in the transcript buffer, and copy it to the clipboard in such a way
> that would (i) remove the command prompts; and (2) comment out all output.
> Also an option to select a region in the main ESS buffer, and copy it to the
> clipboard with the above done automatically, would save quite a bit of
> manual work, at least for me -- usually I want to have at least some of the
> output as comments in the code.
I hear you.
I use to work like that.
First it was lines of Splus code and output I copied from a terminal
window and pasted into a text file, along with my own comments, todo
reminders, journal references, and all kinds of things. Then I would
copy-and-paste those lines of code back into a terminal window, edit
them in place and rerun them. By modern standards this was very ugly,
but a vast improvement over the stacks of paper that used to fill my
office and files.
Then I heard about S-mode, and later ESS and R. And I would edit R
code in ess-mode sometimes with output pasted into comments to explain
what was going on. When it matured, it might migrate to an R package
or Sweave document.
More recently I learned about org-babel:
thanks to a posting by Eric Iverson pointing to his blog, I think. See
for his intro.
You can save R code and edit it using ess-mode and save the printed output
in the same document. You can view inline the graphics R created, edit
spreadsheet data that you can read into R, and have it all in one file.
You can organize it all by section, subsection, etc, and hide/show each
section with a keystroke and move them around as blocks.
You can tangle (extract) the code to produce source()able *.R files or
produce finished reports in various formats.
For another example see
> On Sat, Aug 14, 2010 at 8:32 PM, Charles C. Berry <cberry at tajo.ucsd.edu>wrote:
>> On Sat, 14 Aug 2010, Alex Bokov wrote:
>> I've been working with R for a couple of years, but I have taken the
>>> plunge into emacs and ESS only recently. I was surprised by how much I was
>>> able to figure out about using ESS by searching on my own, but the following
>>> two questions are still stumping me and I hope someone here can help.
>>> 1. If I quit an R session without quitting the buffer then later start
>>> a new one in that buffer, it will append to the existing buffer contents
>>> after delimiting them with a form-feed. This would be an improvement over
>>> the native loadhistory() and savehistory() method, except that it only works
>>> until I have to quit emacs. I cannot just save the transcript file with C-x
>>> C-w and restore the buffer state from it later. The .St file gets opened in
>>> ess-transcript mode instead of in R-mode and even though I can still send
>>> previous commands to an R process in a separate buffer, there doesn't seem
>>> to be any way to append to the original .St file. If I save the new R buffer
>>> to an .St file, it overwrites the original.
>>> How can I either append to an .St file or in some other way restore the
>>> exact state of an R buffer after rebooting my laptop?
>> I think that the general advice is to not bother to try this. Instead work
>> from an ess-mode edit buffer (*.R) and send commands to the R process from
>> there using the ess-eval-* commands. (If you do not know these, check the
>> ESS menu or type 'C-h f ess-eval-<TAB> and a buffer listing them all will
>> Save the buffer when you quit. When you restart later
>> M-x find-file whatever.R then
>> C-c C-l
>> will run ess-load-file and you can continue.
>> Every so often, I forget this advice and enter commands at the R prompt. If
>> I want to save this work, I can save it as *.Rt, then clean the transcript,
>> and copy it into or save it as *.R. :-) If you insist on working from the
>> transcript buffer, you can then kill the cleaned buffer without saving and
>> redo find-file, and you are ready to go.
>> 2. Emacs in general and ESS in particular spams me like crazy with
>>> various temporary buffers. What I would like to do is have one frame with a
>>> small collection of buffers I selected that I can cycle through using
>>> previous-buffer and next-buffer. All other buffers would be completely
>>> banned from that frame no matter how important emacs thinks they are and
>>> they would be instead be forced to use a separate frame.
>>> It would also be nice to automatically kill certain sessions as soon as
>>> they stop being in the foreground, but for now I'll settle just for
>>> segregating them all in one frame.
>>> Any suggestions on how to do that?
>> I'd start by looking at
>> I know there are some devotees of 'icicles' on this list, and 'doremi' and
>> some other links might warrant a look.
>>> Thank you
>>> ESS-help at stat.math.ethz.ch mailing list
>> Charles C. Berry (858) 534-2098
>> Dept of Family/Preventive
>> E mailto:cberry at tajo.ucsd.edu UC San Diego
>> http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
>> ESS-help at stat.math.ethz.ch mailing list
> [[alternative HTML version deleted]]
> ESS-help at stat.math.ethz.ch mailing list
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the ESS-help