This package extends org-babel to allow asynchronous session evaluation.
It currently implements async session evaluation for R, and also provides functionality for implementing async session evaluation in other language modes that use comint.
This package is still in an experimental stage, and not available in MELPA.
However, the code is fairly robust now, and I am using it regularly for my day-to-day data analysis in R.
The org-mode mailing list has recently expressed interest in including this code in org-mode (thread), and a medium-term goal of the project is to contribute this functionality back upstream to org-mode.
My next short-term goal is to implement this functionality for at least one other language, probably Python.
First ensure the lisp/
directory is in your load-path
, and R
is
in org-babel-load-languages
. Then, (require
'ob-session-async-R)
. You will then be able to asynchronously
evaluate R code blocks like the below:
#+begin_src R :async :session
Sys.sleep(5)
"this won't hang your emacs"
#+end_src
- emacs-jupyter enables using jupyter kernels with org-babel source blocks, and supports async session evaluation. It’s an excellent package and I like using it, especially with Python. However, there are some situations where I’d rather not use jupyter, which lead me to writing this package. For example, when using R, I prefer the ESS (Emacs Speaks Statistics) environment over the jupyter IRkernel.
- ob-async enables async
evaluation for regular (non-session) org-babel source blocks. It
does not support the
:session
header argument for evaluating multiple source blocks in an existing session.
Whenever new output is added to the session’s comint buffer, the
function ob-session-async-filter
scans the output for an indicator
token. Upon encountering the token, the filter uses a regular
expression to extract a UUID or temp-file associated with the result,
then searches for the appropriate location to add the result in.
This code is loosely based on org-babel-comint-with-output
in
ob-comint.el
, which is the upstream code in org-mode to evaluate
code in a comint session and return the output.
A lot of the code in this package is just copied from org-mode, then slightly adjusted to accommodate async evaluation. I plan to eventually refactor the code and contribute it back upstream to org-mode, to reduce code duplication and improve code reuse.