Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to ignore sessions only #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ Example:
For additional context, see
https://github.com/astahlman/ob-async/pull/35.

### ob-async-ignore-sessions

This variable allows using `ob-async` for nonsession blocks, while
using alternative `:async` implementations for session blocks. This
may be useful for languages like `ob-python` and `ob-R`, which have
built-in `:async` implementations for sessions, but don't handle
`:async` for nonsessions.

This variable can be a list, in which case it is like
`ob-async-no-async-languages-alist` but for sessions
only. Alternatively, it can be set to `t` to have `ob-async` always
ignore session blocks.

### ob-async-pre-execute-src-block-hook

Some org-babel languages require additional user configuration. For
Expand Down
14 changes: 14 additions & 0 deletions ob-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
compatibility for other languages, e.g. ipython, for which async
functionality may be implemented separately.")

(defvar ob-async-ignore-sessions '("python" "R")
"Don't try to use async in sessions for these languages.
Like `ob-async-no-async-languages-alist', but only for
sessions. Can alternatively be set to `t', in which case ob-async
ignores sessions for all languages.")

(defvar ob-async-pre-execute-src-block-hook nil
"Hook run in the async child process prior to executing a src
block. You can use this hook to perform language-specific
Expand Down Expand Up @@ -85,6 +91,14 @@ block."
;; If there is no :async parameter, call the original function
((not (assoc :async (nth 2 (or info (org-babel-get-src-block-info)))))
(funcall orig-fun arg info params))
;; If a session, check ob-async-ignore-sessions to determine
;; whether to call the original function
((and (assoc :session (nth 2 (or info (org-babel-get-src-block-info))))
(or (equal ob-async-ignore-sessions t)
(and (listp ob-async-ignore-sessions)
(member (nth 0 (or info (org-babel-get-src-block-info)))
ob-async-ignore-sessions))))
(funcall orig-fun arg info params))
;; If the src block language is in the list of languages async is not to be
;; used for, call the original function
((member (nth 0 (or info (org-babel-get-src-block-info)))
Expand Down