mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-04 15:41:37 -05:00
Add jupyter-comm-id
Used to get an identification string of the connection that a kernel client is using.
This commit is contained in:
parent
1e84b42f42
commit
44c3c1a9ea
2 changed files with 18 additions and 4 deletions
|
@ -100,6 +100,12 @@ called if needed. This means that a call to
|
|||
By default, on the last OBJ removed, `jupyter-comm-stop' is
|
||||
called if needed.")
|
||||
|
||||
(cl-defgeneric jupyter-comm-id ((comm jupyter-comm-layer))
|
||||
"Return an identification string for COMM.
|
||||
Can be used to identify this communication channel. For example,
|
||||
used in `jupyter-repl-scratch-buffer' to name the scratch
|
||||
buffer.")
|
||||
|
||||
(cl-defgeneric jupyter-event-handler (_obj _event)
|
||||
"Handle EVENT using OBJ."
|
||||
nil)
|
||||
|
@ -218,6 +224,11 @@ called if needed.")
|
|||
(error "Need threading support"))
|
||||
(cl-call-next-method))
|
||||
|
||||
(cl-defmethod jupyter-comm-id ((comm jupyter-sync-channel-comm))
|
||||
(format "session=%s" (truncate-string-to-width
|
||||
(jupyter-session-id (oref comm session))
|
||||
9 nil nil "…")))
|
||||
|
||||
(defun jupyter-sync-channel-comm--check (comm)
|
||||
(condition-case err
|
||||
(cl-loop
|
||||
|
@ -357,6 +368,11 @@ called if needed.")
|
|||
(cl-call-next-method)
|
||||
(oset comm ioloop (jupyter-channel-ioloop)))
|
||||
|
||||
(cl-defmethod jupyter-comm-id ((comm jupyter-channel-ioloop-comm))
|
||||
(format "session=%s" (truncate-string-to-width
|
||||
(jupyter-session-id (oref comm session))
|
||||
9 nil nil "…")))
|
||||
|
||||
(cl-defmethod jupyter-initialize-connection ((comm jupyter-channel-ioloop-comm)
|
||||
(session jupyter-session))
|
||||
(cl-call-next-method)
|
||||
|
|
|
@ -1638,10 +1638,8 @@ Return the buffer switched to."
|
|||
(interactive)
|
||||
(if (jupyter-repl-connected-p)
|
||||
(let* ((client jupyter-current-client)
|
||||
(name (format "*jupyter-scratch[session=%s]*"
|
||||
(truncate-string-to-width
|
||||
(jupyter-session-id (oref client session))
|
||||
9 nil nil "…"))))
|
||||
(name (format "*jupyter-scratch[%s]*"
|
||||
(jupyter-comm-id (oref client kcomm)))))
|
||||
(unless (get-buffer name)
|
||||
(with-current-buffer (get-buffer-create name)
|
||||
(funcall (jupyter-kernel-language-mode client))
|
||||
|
|
Loading…
Add table
Reference in a new issue