File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -137,12 +137,28 @@ why it isn't returning valid JSON."))))
137137 kernelspecs))
138138
139139(cl-defgeneric jupyter-kernelspecs (host &optional refresh)
140- " Return a list of kernelspecs on HOST." )
140+ " Return a list of kernelspecs on HOST.
141+ If REFRESH is non-nil, then refresh the list of cached
142+ kernelspecs first. Otherwise a cached version of the kernelspecs
143+ may be returned." )
141144
142145(cl-defmethod jupyter-kernelspecs ((host string) &optional refresh)
143146 (let ((default-directory host))
144147 (jupyter-available-kernelspecs refresh)))
145148
149+ (cl-defmethod jupyter-do-refresh-kernelspecs ()
150+ (jupyter-kernelspecs default-directory 'refresh ))
151+
152+ ;;;### autoload
153+ (defun jupyter-refresh-kernelspecs ()
154+ " Refresh the list of available kernelspecs.
155+ Execute this command if the kernelspecs seen by Emacs is out of
156+ sync with those specified on your system or notebook server."
157+ (interactive )
158+ (message " Refreshing kernelspecs... " )
159+ (jupyter-do-refresh-kernelspecs)
160+ (message " Refreshing kernelspecs...done " ))
161+
146162(defun jupyter-get-kernelspec (name &optional specs refresh )
147163 " Get the kernelspec for a kernel named NAME.
148164If no kernelspec is found, return nil. Otherwise return the
Original file line number Diff line number Diff line change @@ -417,7 +417,7 @@ the host."
417417 (setq session (org-babel-read session)))
418418 (org-babel-jupyter-initiate-session-by-key session params)))
419419
420- ; ;;; `org-babel-execute:jupyter'
420+ ; ;;; Helper functions
421421
422422;;;### autoload
423423(defun org-babel-jupyter-scratch-buffer ()
@@ -430,6 +430,17 @@ the host."
430430 (if buffer (pop-to-buffer buffer)
431431 (user-error " No source block at point" ))))
432432
433+ (cl-defmethod jupyter-do-refresh-kernelspecs (&context (major-mode org-mode))
434+ (or (jupyter-org-when-in-src-block
435+ (let* ((info (org-babel-get-src-block-info 'light ))
436+ (params (nth 2 info))
437+ (session (org-babel-read (alist-get :session params))))
438+ (when (file-remote-p session)
439+ (jupyter-kernelspecs session 'refresh ))))
440+ (cl-call-next-method )))
441+
442+ ; ;;; `org-babel-execute:jupyter'
443+
433444(defvar org-bracket-link-regexp )
434445
435446(defun org-babel-jupyter-cleanup-file-links ()
You can’t perform that action at this time.
0 commit comments