mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 17:11:41 -05:00
Notebook can be deleted now
This commit is contained in:
parent
93ba882240
commit
9024f273b2
2 changed files with 35 additions and 3 deletions
|
@ -113,8 +113,25 @@
|
||||||
(message "Creating a new notebook... Done.")))
|
(message "Creating a new notebook... Done.")))
|
||||||
(list (current-buffer))))
|
(list (current-buffer))))
|
||||||
|
|
||||||
;; FIXME: implement notebook deletion.
|
(defun ein:notebooklist-delete-notebook-ask (notebook-id name)
|
||||||
;; See `add_delete_button' in `notebooklist.js'.
|
(when (y-or-n-p (format "Delete notebook %s?" name))
|
||||||
|
(ein:notebooklist-delete-notebook notebook-id name)))
|
||||||
|
|
||||||
|
(defun ein:notebooklist-delete-notebook (notebook-id name)
|
||||||
|
(message "Deleting notebook %s..." name)
|
||||||
|
(let ((url (ein:url-no-cache
|
||||||
|
(ein:notebook-url-from-url-and-id
|
||||||
|
(ein:$notebooklist-url-or-port ein:notebooklist)
|
||||||
|
notebook-id)))
|
||||||
|
(url-request-method "DELETE"))
|
||||||
|
(url-retrieve
|
||||||
|
url
|
||||||
|
(lambda (s buffer name)
|
||||||
|
(kill-buffer (current-buffer))
|
||||||
|
(message "Deleting notebook %s... Done." name)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(ein:notebooklist-reload)))
|
||||||
|
(list (current-buffer) name))))
|
||||||
|
|
||||||
(defun ein:notebooklist-render ()
|
(defun ein:notebooklist-render ()
|
||||||
"Render notebook list widget.
|
"Render notebook list widget.
|
||||||
|
@ -150,7 +167,17 @@ Notebook list data is passed via the buffer local variable
|
||||||
ein:notebooklist)
|
ein:notebooklist)
|
||||||
notebook-id)))
|
notebook-id)))
|
||||||
"Open")
|
"Open")
|
||||||
(widget-insert " " name)
|
(widget-insert " ")
|
||||||
|
(widget-create
|
||||||
|
'link
|
||||||
|
:notify (lexical-let ((name name)
|
||||||
|
(notebook-id notebook-id))
|
||||||
|
(lambda (&rest ignore)
|
||||||
|
(ein:notebooklist-delete-notebook-ask
|
||||||
|
notebook-id
|
||||||
|
name)))
|
||||||
|
"Delete")
|
||||||
|
(widget-insert " : " name)
|
||||||
(widget-insert "\n")))
|
(widget-insert "\n")))
|
||||||
(use-local-map ein:notebook-keymap)
|
(use-local-map ein:notebook-keymap)
|
||||||
(widget-setup))
|
(widget-setup))
|
||||||
|
|
|
@ -70,6 +70,11 @@ INITVALUE and DOCSTRING are passed to `defvar'."
|
||||||
(ein:trim-left p "/")))
|
(ein:trim-left p "/")))
|
||||||
finally return url))
|
finally return url))
|
||||||
|
|
||||||
|
(defun ein:url-no-cache (url)
|
||||||
|
"Imitate `cache=false' of `jQuery.ajax'.
|
||||||
|
See: http://api.jquery.com/jQuery.ajax/"
|
||||||
|
(concat url (format-time-string "?_=%s")))
|
||||||
|
|
||||||
|
|
||||||
;;; JSON utils
|
;;; JSON utils
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue