[ESS] using R + ess-remote with screen in Emacs
S.J.Eglen at damtp.cam.ac.uk
Mon Jul 12 11:01:28 CEST 2010
Thanks for this -- would you mind adding a copy on the ESS wiki, if
Vinh Nguyen <vqnguyen at uci.edu> wrote:
> Dear list,
> I brought up [this](https://stat.ethz.ch/pipermail/ess-help/2009-June/005388.html)
> issue before but a good solution never arised: being able to use
> screen on a remote server (so if something goes wrong on my side I can
> always resume that R session) inside of emacs in order to utilize ESS.
> The closest [thing](http://blog.nguyenvq.com/2009/06/01/run-screen-in-emacs-with-ansi-term-combine-this-with-emacs-ess-remote-r/)
> I found to a good work flow was to use ansi-term or multi-term and
> copying and pasting code in Emacs (ESS only worked nicely with
> shell-mode; reason at the end). Some would advise to use screen and
> open emacs inside of that screen, and voila, you have the luxuries of
> screen (attaching the session anywhere) and emacs+ESS (keybindings,
> etc). However, I prefer to use one main emacs session on my
> laptop/netbook (all my configurations are there), where I can have
> multiple projects and multiple R jobs opened at once.
> I would like to share what I have working (for the time being), with
> the help of [Michael Zeller](http://home.michaelzeller.com/) in case
> others are interested.
> 1. Place the following in .emacs:
> ;; used to send screen keybindings to shell in emacs
> (define-key shell-mode-map (kbd "C-l") (lambda (seq) (interactive "k")
> (process-send-string nil seq)))
> (define-key inferior-ess-mode-map (kbd "C-l") (lambda (seq)
> (interactive "k") (process-send-string nil seq)))
> 2. In xterm (or the likes), ssh to the remote server and start
> screen. Detach it. (Need to do this first as starting the initial
> screen in emacs shell-mode becomes very ugly with the printing;
> resuming the same screen session also becomes messy in xterm)
> 3. In emacs, M-x shell. Set:
> $ TERM=xterm ## give clearing capabilities to shell-mode
> 4. ssh to remote server. screen -r to resume the screen session.
> start R. M-x ess-remote.
> 5. Send R code from R source files like before!
> 6. To detach or do anything screen related, precede EACH keybinding
> with C-l. For example, C-a C-d to detach will now be C-l C-a C-l C-d.
> Yes this is cumbersome, but I don't imagine screen keybinding to be
> used much at this stage since we are developing and debugging R code
> for say a simulation study =].
> I would also like to note (for archival reasons) that ess-remote does
> not work with ansi-term and multi-term because of the
> inferior-ess-mode command, which stems from comint-mode and
> inferior-ess-send-input. If you remove this command in ess-remote,
> you don't get an error but u can only send one line of code at a time
> from the R file.
> Hope this helps someone out there.
> Vinh Nguyen
> PS This post is also posted on my blog at
> ESS-help at stat.math.ethz.ch mailing list
More information about the ESS-help