mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Save a copy of the notebook, fix deleting notebooks.
Can save a copy of an existing notebook to a new name via `ein:notebook-save-to-command` (I still haven't thought of a good, default keybinding, however). Deleting notebooks now works again.
This commit is contained in:
parent
c669d8aa54
commit
7978961d96
1 changed files with 18 additions and 2 deletions
|
@ -336,9 +336,9 @@ will be updated with kernel's cwd."
|
|||
(ein:$notebook-notebook-path notebook)))
|
||||
|
||||
(defun ein:notebook-url-from-url-and-id (url-or-port api-version path)
|
||||
(cond ((= 2 api-version)
|
||||
(cond ((= api-version 2)
|
||||
(ein:url url-or-port "api/notebooks" path))
|
||||
((>= 3 api-version)
|
||||
((>= api-version 3)
|
||||
(ein:url url-or-port "api/contents" path))))
|
||||
|
||||
(defun ein:notebook-pop-to-current-buffer (&rest -ignore-)
|
||||
|
@ -916,6 +916,22 @@ NAME is any non-empty string that does not contain '/' or '\\'."
|
|||
(ein:log 'info "Renaming notebook at URL %s" (ein:notebook-url ein:%notebook%))
|
||||
(ein:content-rename content path #'ein:notebook-rename-success (list ein:%notebook% content))))
|
||||
|
||||
(defun ein:notebook-save-to-command (path)
|
||||
"Make a copy of the notebook and save it to a new path specified by NAME.
|
||||
NAME is any non-empty string that does not contain '/' or '\\'.
|
||||
"
|
||||
(interactive
|
||||
(list (read-string "Save copy to: " (ein:$notebook-notebook-path ein:%notebook%))))
|
||||
(unless (and (string-match ".ipynb" path) (= (match-end 0) (length path)))
|
||||
(setq path (format "%s.ipynb" path)))
|
||||
(let* ((content (ein:content-from-notebook ein:%notebook%))
|
||||
(name (substring path (or (cl-position ?/ path :from-end t) 0))))
|
||||
(setf (ein:$content-path content) path
|
||||
(ein:$content-name content) name)
|
||||
(ein:content-save content #'ein:notebook-open
|
||||
(list (ein:$notebook-url-or-port ein:%notebook%)
|
||||
path))))
|
||||
|
||||
;; (defun* ein:notebook-rename-error (old new notebook &key symbol-status response
|
||||
;; error-thrown
|
||||
;; &allow-other-keys)
|
||||
|
|
Loading…
Add table
Reference in a new issue