From a1ef1097a119d9c8a15f8e862365a460a133b2ef Mon Sep 17 00:00:00 2001 From: torfjelde Date: Sat, 17 Sep 2022 22:54:07 +0100 Subject: [PATCH 1/2] allow disabling async by using :async no --- ob-async.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ob-async.el b/ob-async.el index f4ed207..915a126 100644 --- a/ob-async.el +++ b/ob-async.el @@ -82,8 +82,9 @@ block." ((not orig-fun) (warn "ob-async-org-babel-execute-src-block is no longer needed in org-ctrl-c-ctrl-c-hook") nil) - ;; If there is no :async parameter, call the original function - ((not (assoc :async (nth 2 (or info (org-babel-get-src-block-info))))) + ;; If there is no `:async' parameter or we have `:async no', call the original function + ((let ((async-maybe (assoc :async (nth 2 (or info (org-babel-get-src-block-info)))))) + (or (not async-maybe) (string-equal (cdr async-maybe) "no"))) (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 From db86ab9b1ed5dedeb95f92ac98224c15d817bc06 Mon Sep 17 00:00:00 2001 From: torfjelde Date: Sat, 17 Sep 2022 23:21:01 +0100 Subject: [PATCH 2/2] added test for :async no --- test/ob-async-test.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/ob-async-test.el b/test/ob-async-test.el index 63216d5..2efae28 100644 --- a/test/ob-async-test.el +++ b/test/ob-async-test.el @@ -91,6 +91,18 @@ POST-FORM is executed after the src-block finishes execution" (org-ctrl-c-ctrl-c) (should (string= "Sorry for the wait." (results-block-contents)))))) +(ert-deftest test-async-no () + "Testing ignoring async when `:async no' is set." + (let ((buffer-contents "Here's a shell source block: + + #+BEGIN_SRC sh :async no + sleep 1s && echo 'Sorry for the wait.' + #+END_SRC")) + (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: