remacsess

How can I background the R process in ESS / Emacs?


I often run long R scripts when I start my R environment. I would like to be able to load / run the R script in Emacs / ESS and continue other work in another buffer.

When I press C-g or C-c C-c the process is interrupted, and I must restart the script.

What is the best way to background the R process in ESS / Emacs?

EDIT: Thank you for your answers and comments, but none of them address the fact that Emacs freezes when you load / run a large script and you can't change buffer.

I suppose my question is a little more general - can Emacs background a process to let you keep working?


Solution

  • ESS runs R as asynchronous process. You don't need to background anything. You can run your code for hours and still work in ESS uninterrupted.

    Your problem seems to be something else. When you execute your script you do it "visibly", i.e. your executed code is printed to the terminal. This cause Emacs to freeze.

    Set ess-eval-visibly to nil and huge chunks of code will be sent to R instantly:

    (setq ess-eval-visibly nil)
    

    Cheers.

    Update

    There is a new setting for ess-eval-visibly in recent versions of ESS - 'nowait. It places your code in an inferior buffer and then sends it to the subprocess. In this way you can see your code and all the output afterwards without waiting for the subprocess to finish.