mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Use session query to show running kernels.
Stopping a kernel now doesn't automatically close a buffer, nor does closing a buffer automatically stop a running kernel. This is functionality more in line of what EIN supported for IPython 0.x and 1.x.
This commit is contained in:
parent
81583c4411
commit
0cf283a43b
2 changed files with 17 additions and 17 deletions
|
@ -636,11 +636,8 @@ Example::
|
|||
(ein:log 'info "Sent interruption command.")))))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(defun ein:kernel-kill (kernel &optional callback cbargs)
|
||||
(when (ein:$kernel-running kernel)
|
||||
(when kernel
|
||||
(ein:query-singleton-ajax
|
||||
(list 'kernel-kill (ein:$kernel-session-id kernel))
|
||||
(ein:url (ein:$kernel-url-or-port kernel)
|
||||
|
@ -650,10 +647,11 @@ Example::
|
|||
:success (apply-partially
|
||||
(lambda (kernel callback cbargs &rest ignore)
|
||||
(ein:log 'info "Notebook session killed.")
|
||||
(setf (ein:$kernel-running kernel) nil)
|
||||
(if kernel
|
||||
(setf (ein:$kernel-running kernel) nil))
|
||||
(when callback (apply callback cbargs)))
|
||||
kernel callback cbargs))))
|
||||
|
||||
g
|
||||
|
||||
;; Reply handlers.
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ Notebook list data is passed via the buffer local variable
|
|||
(erase-buffer))
|
||||
(remove-overlays)
|
||||
;; Create notebook list
|
||||
(widget-insert "IPython Notebook list\n\n")
|
||||
(widget-insert (format "IPython %s Notebook list\n\n" (ein:$notebooklist-api-version ein:%notebooklist%)))
|
||||
(let ((breadcrumbs (generate-breadcrumbs (ein:$notebooklist-path ein:%notebooklist%))))
|
||||
(dolist (p breadcrumbs)
|
||||
(lexical-let ((name (car p))
|
||||
|
@ -375,7 +375,7 @@ Notebook list data is passed via the buffer local variable
|
|||
(ein:$notebooklist-url-or-port ein:%notebooklist%)
|
||||
path))
|
||||
name)))
|
||||
(widget-insert " |\n"))
|
||||
(widget-insert " |\n\n"))
|
||||
(widget-create
|
||||
'link
|
||||
:notify (lambda (&rest ignore) (ein:notebooklist-new-notebook))
|
||||
|
@ -392,8 +392,10 @@ Notebook list data is passed via the buffer local variable
|
|||
(browse-url
|
||||
(ein:url (ein:$notebooklist-url-or-port ein:%notebooklist%))))
|
||||
"Open In Browser")
|
||||
(widget-insert "\n")
|
||||
(let ((api-version (ein:$notebooklist-api-version ein:%notebooklist%)))
|
||||
(widget-insert "\n\n")
|
||||
(let ((api-version (ein:$notebooklist-api-version ein:%notebooklist%))
|
||||
(sessions (make-hash-table :test 'equal)))
|
||||
(ein:content-query-sessions sessions (ein:$notebooklist-url-or-port ein:%notebooklist%) t)
|
||||
(loop for note in (ein:$notebooklist-data ein:%notebooklist%)
|
||||
for urlport = (ein:$notebooklist-url-or-port ein:%notebooklist%)
|
||||
for name = (plist-get note :name)
|
||||
|
@ -404,6 +406,7 @@ Notebook list data is passed via the buffer local variable
|
|||
;; (ein:get-actual-path (plist-get note :path))))
|
||||
for type = (plist-get note :type)
|
||||
for opened-notebook-maybe = (ein:notebook-get-opened-notebook urlport path)
|
||||
do (widget-insert " ")
|
||||
if (string= type "directory")
|
||||
do (progn (widget-create
|
||||
'link
|
||||
|
@ -428,18 +431,17 @@ Notebook list data is passed via the buffer local variable
|
|||
ein:%notebooklist% path)))
|
||||
"Open")
|
||||
(widget-insert " ")
|
||||
(when (and opened-notebook-maybe (ein:kernel-live-p (ein:$notebook-kernel opened-notebook-maybe)))
|
||||
(when (gethash path sessions)
|
||||
(widget-create
|
||||
'link
|
||||
:notify (lexical-let ((urlport urlport)
|
||||
(path path))
|
||||
:notify (lexical-let ((session (car (gethash path sessions)))
|
||||
(nblist ein:%notebooklist%))
|
||||
(lambda (&rest ignore)
|
||||
(let ((buf (ein:notebook-get-opened-buffer urlport path)))
|
||||
(when buf
|
||||
(run-at-time 1 nil
|
||||
(run-at-time 1 nil
|
||||
#'ein:notebooklist-reload
|
||||
ein:%notebooklist%)
|
||||
(kill-buffer buf)))))
|
||||
(ein:kernel-kill (make-ein:$kernel :url-or-port (ein:$notebooklist-url-or-port nblist)
|
||||
:session-id session))))
|
||||
"Stop")
|
||||
(widget-insert " "))
|
||||
(widget-create
|
||||
|
|
Loading…
Add table
Reference in a new issue