mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 23:41:38 -05:00
jupyter-run-repl: Abstract out server determination code
This commit is contained in:
parent
a60699c3fa
commit
ba79115fc4
1 changed files with 16 additions and 10 deletions
|
@ -2049,7 +2049,21 @@ completing all of the above.")
|
|||
(jupyter-repl-insert-banner banner)
|
||||
(jupyter-repl-insert-prompt 'in)))))))
|
||||
|
||||
(defvar jupyter--run-repl-server nil)
|
||||
(defvar jupyter--repl-server nil)
|
||||
|
||||
(defun jupyter-repl-server ()
|
||||
"Return a `jupyter-server' that can be used to launch REPLs with.
|
||||
The server is used by the `jupyter-run-repl' command to launch
|
||||
all of its REPLs if ZMQ based connections are not being used."
|
||||
(let ((server jupyter--repl-server))
|
||||
(if (and server
|
||||
(process-live-p
|
||||
(jupyter-notebook-process server)))
|
||||
server
|
||||
(let* ((port (jupyter-launch-notebook))
|
||||
(url (format "http://localhost:%s" port)))
|
||||
(setq jupyter--repl-server
|
||||
(jupyter-server :url url))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun jupyter-run-repl (kernel-name &optional repl-name associate-buffer client-class display)
|
||||
|
@ -2093,15 +2107,7 @@ command on the host."
|
|||
(if jupyter-use-zmq
|
||||
(jupyter-kernel :spec spec)
|
||||
(jupyter-kernel
|
||||
:server (let ((server jupyter--run-repl-server))
|
||||
(if (and server
|
||||
(process-live-p
|
||||
(jupyter-notebook-process server)))
|
||||
server
|
||||
(let* ((port (jupyter-launch-notebook))
|
||||
(url (format "http://localhost:%s" port)))
|
||||
(setq jupyter--run-repl-server
|
||||
(jupyter-server :url url)))))
|
||||
:server (jupyter-repl-server)
|
||||
:spec spec))
|
||||
client-class))
|
||||
repl-name associate-buffer display))
|
||||
|
|
Loading…
Add table
Reference in a new issue