jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

Is there a hook that's being called when the kernel returns from evaluating a cell?

Open JonatanSahar opened this issue 1 year ago • 1 comments

I've found jupyter-repl-cell-post-send-hook for the begining of evaluation, and jupyter-add-hook, but I'm not sure if that runs when I think it does, nor what values CLIENT will accept..

Thanks!

JonatanSahar avatar Jun 30 '24 07:06 JonatanSahar

There are the jupyter-shell-message-hook and the like.

You can use them like so

(defun nn/on-execute-reply (client msg)
  (when (equal (jupyter-message-type msg) "execute_reply")
    (let ((req
           ;; The actual `jupyter-request' object associated with the
           ;; message.  You can access all the messages associated
           ;; with the request using `jupyter-request-messages'.
           (plist-get msg :parent-request)))
      ;; Do something
      )))

(jupyter-add-hook client 'jupyter-shell-message-hook #'nn/on-execute-reply)

You can add to jupyter-shell-message-hook (the global value) using just add-hook to do something for every client.

nnicandro avatar Jul 18 '24 02:07 nnicandro