mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 23:41:38 -05:00
Introduce jupyter-repl-propagate-client
This commit is contained in:
parent
da222cf5e0
commit
c65803448a
1 changed files with 19 additions and 1 deletions
|
@ -1964,8 +1964,26 @@ enabling `jupyter-repl-interaction-mode'."
|
||||||
(define-key map (kbd "C-c C-z") #'jupyter-repl-pop-to-buffer)
|
(define-key map (kbd "C-c C-z") #'jupyter-repl-pop-to-buffer)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
|
(defun jupyter-repl-propagate-client (orig-fun buffer-or-name &rest args)
|
||||||
|
"Propgate the `jupyter-repl-current-client' to other buffers."
|
||||||
|
(when jupyter-repl-interaction-mode
|
||||||
|
(let ((client jupyter-repl-current-client)
|
||||||
|
(buf (get-buffer buffer-or-name))
|
||||||
|
(mode major-mode))
|
||||||
|
(when buf
|
||||||
|
(with-current-buffer buf
|
||||||
|
(when (and (eq mode major-mode)
|
||||||
|
(not jupyter-repl-interaction-mode))
|
||||||
|
(jupyter-repl-associate-buffer client))))))
|
||||||
|
(apply orig-fun buffer-or-name args))
|
||||||
|
|
||||||
|
(advice-add 'switch-to-buffer :around #'jupyter-repl-propagate-client)
|
||||||
|
|
||||||
(define-minor-mode jupyter-repl-interaction-mode
|
(define-minor-mode jupyter-repl-interaction-mode
|
||||||
"Minor mode for interacting with a Jupyter REPL."
|
"Minor mode for interacting with a Jupyter REPL.
|
||||||
|
Note that for buffers with `jupyter-repl-interaction-mode'
|
||||||
|
enabled, any new buffer opened with the same `major-mode' will
|
||||||
|
automatically have its buffer associated with the REPL."
|
||||||
:group 'jupyter-repl
|
:group 'jupyter-repl
|
||||||
:lighter " JuPy"
|
:lighter " JuPy"
|
||||||
:init-value nil
|
:init-value nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue