From b29d47529ebc0eb087b06060ad3b102e33f16bbe Mon Sep 17 00:00:00 2001 From: "A. Kirkpatrick" Date: Thu, 12 Nov 2020 15:55:48 +1030 Subject: [PATCH 1/2] Prevent result overlays from causing subprocess failure While running ob-async I kept getting this error: if: Invalid read syntax: "#" When I enabled async-debug I found the culprit, overlays for babel results that I had toggled to be hidden: ELISP> org-babel-hide-result-overlays (#) This change excludes `org-babel-hide-result-overlays' specifically, but a more general fix would test the value of each variable sent to the subprocess to ensure it can be serialized. --- ob-async.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ob-async.el b/ob-async.el index cdc06af..7eb50a8 100644 --- a/ob-async.el +++ b/ob-async.el @@ -155,7 +155,7 @@ block." (setq exec-path ',exec-path) (setq load-path ',load-path) ;; setq any variables that are prefixed with "org-babel-" - ,(async-inject-variables "\\borg-babel.+") + ,(async-inject-variables "\\borg-babel.+" nil "^org-babel-hide-result-overlays$") (package-initialize) (setq ob-async-pre-execute-src-block-hook ',ob-async-pre-execute-src-block-hook) (run-hooks 'ob-async-pre-execute-src-block-hook) From ae6984108a9407604a1f31dcce6a00d89ca8f01c Mon Sep 17 00:00:00 2001 From: "A. Kirkpatrick" Date: Thu, 12 Nov 2020 16:18:13 +1030 Subject: [PATCH 2/2] ert-deftest test-org-babel-hide-result-overlays-suppressed --- test/ob-async-test.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/ob-async-test.el b/test/ob-async-test.el index 1531fdf..cc59c0c 100644 --- a/test/ob-async-test.el +++ b/test/ob-async-test.el @@ -442,3 +442,20 @@ inherited by the async subprocess" (ctrl-c-ctrl-c-with-callbacks :pre (should (placeholder-p (results-block-contents))) :post (should (string= "I should be set!" (results-block-contents))))))))) + +(ert-deftest test-org-babel-hide-result-overlays-suppressed () + "Test that org-babel-hide-result-overlays is not inherited by +the async subprocess" + (let* ((uuid (ob-async--generate-uuid)) + (buffer-contents " +#+BEGIN_SRC emacs-lisp :async + org-babel-hide-result-overlays +#+END_SRC")) + (unwind-protect + (progn + (with-buffer-contents buffer-contents + (setq org-babel-hide-result-overlays (list (make-overlay 1 1))) + (org-babel-next-src-block) + (ctrl-c-ctrl-c-with-callbacks + :pre (should (placeholder-p (results-block-contents))) + :post (should (string= "nil" (results-block-contents)))))))))