Make scratch buffers easier to identify

This commit is contained in:
Tomasz Mieszkowski 2021-11-27 19:32:30 +01:00 committed by Nathaniel Nicandro
parent 7b64e18144
commit 57306bf385
2 changed files with 4 additions and 5 deletions

View file

@ -112,9 +112,7 @@ 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.")
Can be used to identify this communication channel.")
(cl-defgeneric jupyter-event-handler (_obj _event)
"Handle EVENT using OBJ."

View file

@ -1653,8 +1653,9 @@ Return the buffer switched to."
(interactive)
(if (jupyter-repl-connected-p)
(let* ((client jupyter-current-client)
(name (format "*jupyter-scratch[%s]*"
(jupyter-comm-id (oref client kcomm)))))
(name (replace-regexp-in-string "^*jupyter-repl"
"*jupyter-scratch"
(buffer-name) (oref client buffer))))
(unless (get-buffer name)
(with-current-buffer (get-buffer-create name)
(funcall (jupyter-kernel-language-mode client))