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."))))
137
137
kernelspecs))
138
138
139
139
(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." )
141
144
142
145
(cl-defmethod jupyter-kernelspecs ((host string) &optional refresh)
143
146
(let ((default-directory host))
144
147
(jupyter-available-kernelspecs refresh)))
145
148
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
+
146
162
(defun jupyter-get-kernelspec (name &optional specs refresh )
147
163
" Get the kernelspec for a kernel named NAME.
148
164
If 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."
417
417
(setq session (org-babel-read session)))
418
418
(org-babel-jupyter-initiate-session-by-key session params)))
419
419
420
- ; ;;; `org-babel-execute:jupyter'
420
+ ; ;;; Helper functions
421
421
422
422
;;;### autoload
423
423
(defun org-babel-jupyter-scratch-buffer ()
@@ -430,6 +430,17 @@ the host."
430
430
(if buffer (pop-to-buffer buffer)
431
431
(user-error " No source block at point" ))))
432
432
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
+
433
444
(defvar org-bracket-link-regexp )
434
445
435
446
(defun org-babel-jupyter-cleanup-file-links ()
You can’t perform that action at this time.
0 commit comments