Work around a bug when using jupyter-with-client in jupyter-kernel-info

There would be a `max-lisp-eval-depth` error issued when attempting to
let bind `jupyter-current-client` for some reason.
This commit is contained in:
Nathaniel Nicandro 2022-01-14 15:14:49 -06:00
parent 3b94b2b4dc
commit 801a2d9da3

View file

@ -1659,20 +1659,25 @@ name are changed to \"-\" and all uppercase characters lowered."
(or (oref client kernel-info) (or (oref client kernel-info)
(progn (progn
(message "Requesting kernel info...") (message "Requesting kernel info...")
(let ((jupyter-current-client client)) (let ((old-client jupyter-current-client)
(jupyter-mlet* ((msg (jupyter-reply (old-io jupyter-current-io))
(jupyter-kernel-info-request (setq jupyter-current-client client)
:handlers nil) (setq jupyter-current-io (or (car (oref jupyter-current-client io))
(* 3 jupyter-long-timeout)))) (error "Client not connected to a kernel")))
(message "Requesting kernel info...done") (unwind-protect
(oset client kernel-info (jupyter-message-content msg)) (jupyter-mlet* ((msg (jupyter-reply
;; Canonicalize language name to a language symbol for (jupyter-kernel-info-request
;; method dispatching :handlers nil)
(let* ((info (plist-get (oref client kernel-info) :language_info)) (* 3 jupyter-long-timeout))))
(lang (plist-get info :name)) (message "Requesting kernel info...done")
(name (jupyter-canonicalize-language-string lang))) (oset client kernel-info (jupyter-message-content msg))
(plist-put info :name (intern name))))) (let* ((info (plist-get (oref client kernel-info) :language_info))
(oref client kernel-info)))) (lang (plist-get info :name))
(name (jupyter-canonicalize-language-string lang)))
(plist-put info :name (intern name))))
(setq jupyter-current-client old-client)
(setq jupyter-current-io old-io))
(oref client kernel-info)))))
(defun jupyter-kernel-language-mode-properties (client) (defun jupyter-kernel-language-mode-properties (client)
"Get the `major-mode' info of CLIENT's kernel language. "Get the `major-mode' info of CLIENT's kernel language.