[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Async evaluation in ob-shell

From: Matt
Subject: Re: [PATCH] Async evaluation in ob-shell
Date: Mon, 27 Mar 2023 22:53:52 -0400
User-agent: Zoho Mail

 ---- On Fri, 24 Mar 2023 05:13:34 -0400  Ihor Radchenko  wrote --- 

 > A small note on the WORG page: it may be more natural to use :async yes
 > rather than :async t. Both are viable - in fact, anything other than
 > :async no and :async none will be treated as "t".
Ah, okay.  I'll make that more clear.

Somewhat related, I had this left over from when I was working out the async 
code.  It prevents the user from running :async without the (required) :session 
header.    The :async header runs the default (blocking) process when :session 
is missing.

diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 86c2bf7a7..384bfcda8 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -206,11 +206,12 @@ comint outputs due to buffering.")
 PARAMS are the header arguments as passed to
   (let ((async (assq :async params))
-        (session (assq :session params)))
+        (sessionp (not (member (cdr (assq :session params)) '("no" "none")))))
+    (if (and async (not sessionp))
+          (error (org-babel-eval-error-notify 1 "ERROR: must use 'async' with 
     (and async
-        (not org-babel-exp-reference-buffer)
-         (not (equal (cdr async) "no"))
-         (not (equal (cdr session) "none")))))
+         sessionp
+         (not org-babel-exp-reference-buffer))))
 (defun org-babel-comint-async-filter (string)
   "Captures Babel async output from comint buffer back to Org mode buffers.

It's really just a nicety.  The user can cancel the accidental blocking process 
with C-g.  However, the block is run in a different shell than expected and 
it's jarring to have Emacs freeze when you expect async.

Thoughts on including it or something similar?

Attachment: error-on-async-session-mismatch.diff
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]