[ESS] emacs hangs / freezes when R hangs

Lars Schmidt-Thieme schmidt-thieme at ismll.de
Tue Oct 5 01:52:58 CEST 2010

Dear ess maintainers,

if you evaluate a line or region in R (ess-eval-line/region), in the current
implementation emacs waits for R to complete. This means esp. that
* you cannot continue to edit while R is computing something concurrently
* if R hangs (e.g., in an infinite loop), emacs hangs / freezes and it is
  difficult to interrupt R.

This behavior has been reported by several users in the past and can
be easily reproduced by evaluating
>  while (T) 1+1;

Attached is a proposal how to change this behavior so that emacs is no
longer waiting for R to complete, but sends the code to R (still line
by line, so input and output still will be nicely aligned), and then
lets the user continue to edit files.
* ess-inf.el is taken from ess 5.7.1 release (as packaged for ubuntu)
  and all places where I changed things have been marked.
* linefeeder.el is a generic solution for sending input line-by-line to
  comint processes.
To test it: just replace ess-inf.el in ess 5.7.1 by the version attached
and add linefeeder.el to the ess lisp directory, then run ess-eval-region
in an R buffer. I tested it with Gnu Emacs 23.1.1, R 2.10.1 and ess 5.7.1
on Linux.

If you could give it a try and consider it for integration in an upcoming
ess release, I would be very happy. Feel free to take the bits you
think are useful.

The idea is very simple: instead of chopping the code into lines
and feeding it line-by-line in the main edit thread (ess-eval-linewise),
one sends just a single line and ends activity in this thread,
catching the next R prompt through a comint-output-filter-function
and then sending the next line.


More information about the ESS-help mailing list