3

I want to execute org-babel code blocks of R code in a particular R session without locking up Emacs. I found the ob-async package, but it doesn't have support for sessions yet. I've found that opening the code block in a source buffer allows me to run code blocks without locking up Emacs. I'm mostly happy with that workflow. I can hit C-' C-b to evaluate R code blocks using ESS, for example.

One annoyance however is that I have to choose the instance to use for execution, if I have multiple R sessions open. This is particularly cumbersome, since I have to do this every time I revisit the code block using C-'. I'd like to have the session automatically associated (using the :session argument in the header). How would I go about doing this?

1 Answer 1

1

I know this is an old question but the solution is:

(defvar tmprs nil) (defun get-org-current-rsession() "When you are in an org file get the current R session based on global header, subtree, property or source code :session property whichever is relevant" (setq tmprs (cdr (assoc :session (nth 2 (org-babel-get-src-block-info t))))) ) (defun set-ess-R-process() "set the process to session stored in tmprs variable" (message "Setting R session to %s" (eval tmprs)) (setq ess-local-process-name (process-name (get-buffer-process tmprs))) ) (advice-add 'org-edit-src-code :before #'get-org-current-rsession) (advice-add 'org-edit-src-code :after #'set-ess-R-process) 

see https://www.fredgruber.org/post/ess_emacs_default_r_session/ for more details

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.