diff --git a/jupyter-org-client.el b/jupyter-org-client.el index eedb658..4d92a42 100644 --- a/jupyter-org-client.el +++ b/jupyter-org-client.el @@ -1268,9 +1268,15 @@ buffer." ;;; org-babel functions ;; These are meant to be called by `org-babel-execute:jupyter' -(defun jupyter-org-insert-async-id (req) - "Insert the ID of REQ. -Meant to be used as the return value of +(defun jupyter-org-pending-async-results (req) + "Finish up bookkeeping for an asynchronous source block REQ. +Setup `org-babel-after-execute-hook' to insert the ID of REQ as +the result of the associated source block, to signify that the +results of REQ are pending, and run any other hook functions that +were present before this function was called. + +This function always returns nil and is intended to be used as +the return value for asynchronous Jupyter source blocks in `org-babel-execute:jupyter'." (prog1 nil (let ((log-max message-log-max) @@ -1278,12 +1284,12 @@ Meant to be used as the return value of (id (jupyter-org-scalar (jupyter-org-request-id req)))) (setq message-log-max nil) (setq org-babel-after-execute-hook - (lambda () - (setq message-log-max log-max) - (unwind-protect - (jupyter-org--add-result req id) - (setq org-babel-after-execute-hook hook) - (run-hooks 'org-babel-after-execute-hook))))))) + (list (lambda () + (setq message-log-max log-max) + (unwind-protect + (jupyter-org--add-result req id) + (setq org-babel-after-execute-hook hook) + (run-hooks 'org-babel-after-execute-hook)))))))) (defun jupyter-org--coalesce-stream-results (results) "Return RESULTS with all contiguous stream results concatenated. diff --git a/ob-jupyter.el b/ob-jupyter.el index 954c0b1..68b681c 100644 --- a/ob-jupyter.el +++ b/ob-jupyter.el @@ -304,7 +304,7 @@ the PARAMS alist." (when (bound-and-true-p org-export-current-backend) (add-hook 'org-babel-after-execute-hook #'sync-on-export t t)) (if (jupyter-org-request-inline-block-p req) "" - (jupyter-org-insert-async-id req)))) + (jupyter-org-pending-async-results req)))) (t (let ((result-params (assq :result-params params))) (when (and (member "file" result-params)