Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

jackkamm/ob-session-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ob-session-async

As of Org 9.5, this package is obsolete, with the core functionality now included in Org mode.

This was a package to extend org-babel to allow asynchronous session evaluation. It implemented async session evaluation for R, Ruby, and Python, and also provides functionality for implementing async session evaluation in other language modes that use comint.

Status

This project has achieved its goal of being added upstream into Org mode. Therefore, I am archiving it.

Installation & usage

First, make sure you have installed Org 9.4 or later.

Next 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

Related packages

  • 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.

How it works

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.

Links

About

Asynchronous org-mode session evaluation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published