org-babel-jupyter-scratch-buffer: Don't switch buffers when inside edit buffer

This commit is contained in:
Nathaniel Nicandro 2019-06-12 23:20:06 -05:00
parent f3b94bab39
commit 1913da83fa
2 changed files with 5 additions and 2 deletions

View file

@ -1633,7 +1633,8 @@ in the appropriate direction, to the saved element."
;;; `jupyter-repl-mode'
(defun jupyter-repl-scratch-buffer ()
"Display a scratch buffer associated with the current REPL buffer."
"Switch to a scratch buffer connected to the current REPL in another window.
Return the buffer switched to."
(interactive)
(if (jupyter-repl-connected-p)
(let* ((client jupyter-current-client)

View file

@ -256,12 +256,14 @@ the host."
(if (equal session "none") (error "Need a session to run")
(org-babel-jupyter-initiate-session-by-key session params)))
;;;###autoload
(defun org-babel-jupyter-scratch-buffer ()
"Display a scratch buffer connected to the current block's session."
(interactive)
(let (buffer)
(org-babel-do-in-edit-buffer
(setq buffer (jupyter-repl-scratch-buffer)))
(setq buffer (save-window-excursion
(jupyter-repl-scratch-buffer))))
(if buffer (pop-to-buffer buffer)
(user-error "No source block at point"))))