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

Add list of languages for ob-async to ignore #35

Merged
merged 3 commits into from
Jun 24, 2018
Merged
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
8 changes: 8 additions & 0 deletions ob-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
(require 'async)
(require 'dash)

(defvar ob-async-no-async-languages-alist nil
"async is not used for languages listed here. Enables compatability for other languages, e.g. ipython, for which async functionality may be implemented separately.")

;;;###autoload
(defalias 'org-babel-execute-src-block:async 'ob-async-org-babel-execute-src-block)

Expand Down Expand Up @@ -70,6 +73,11 @@ 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 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)))
ob-async-no-async-languages-alist)
(funcall orig-fun arg info params))
;; Otherwise, perform asynchronous execution
(t
(let ((placeholder (ob-async--generate-uuid)))
Expand Down
14 changes: 14 additions & 0 deletions test/ob-async-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ See http://stackoverflow.com/questions/14698081/elisp-sleep-for-doesnt-block-whe
(wait-for-seconds 5)
(should (string= "Sorry for the wait." (results-block-contents))))))


(ert-deftest test-async-ignore-lang-sh-block ()
"Testing ignoring a language."
(let ((buffer-contents "Here's a shell source block:

#+BEGIN_SRC sh :async
sleep 1s && echo 'Sorry for the wait.'
#+END_SRC")
(ob-async-no-async-languages-alist '("sh")))
(with-buffer-contents buffer-contents
(org-babel-next-src-block)
(org-ctrl-c-ctrl-c)
(should (string= "Sorry for the wait." (results-block-contents))))))

(ert-deftest test-async-execute-existing-sh-block ()
"Test that we can insert results for a sh block that has already been executed"
(let ((buffer-contents "Here's a shell source block:
Expand Down