mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 17:11:41 -05:00
Save cells in ein:notebook-save-notebook-success
This commit is contained in:
parent
d25f6a1c02
commit
473a16a0a7
2 changed files with 10 additions and 6 deletions
|
@ -216,7 +216,7 @@ call notebook destructor `ein:notebook-del'."
|
|||
(symbol-macrolet ((worksheets (ein:$notebook-worksheets notebook))
|
||||
(scratchsheets (ein:$notebook-scratchsheets notebook)))
|
||||
(cond
|
||||
((ein:worksheet-p ws) (ein:worksheet-save-cells ws))
|
||||
((ein:worksheet-p ws) (ein:worksheet-save-cells ws t))
|
||||
(t (setq scratchsheets (delq ws scratchsheets))))
|
||||
(unless (or (ein:filter (lambda (x)
|
||||
(and (not (eq x ws))
|
||||
|
@ -566,7 +566,9 @@ This is equivalent to do ``C-c`` in the console program."
|
|||
(defun ein:notebook-save-notebook-success (notebook &rest ignore)
|
||||
(ein:log 'info "Notebook is saved.")
|
||||
(setf (ein:$notebook-dirty notebook) nil)
|
||||
(mapc (lambda (ws) (ein:worksheet-set-modified-p ws nil))
|
||||
(mapc (lambda (ws)
|
||||
(ein:worksheet-save-cells ws)
|
||||
(ein:worksheet-set-modified-p ws nil))
|
||||
(ein:$notebook-worksheets notebook))
|
||||
(ein:events-trigger (ein:$notebook-events notebook)
|
||||
'notebook_saved.Notebook))
|
||||
|
|
|
@ -234,17 +234,19 @@ current buffer."
|
|||
`((cells . ,(apply #'vector cells))
|
||||
,@(ein:aand (oref ws :metadata) `((metadata . ,it))))))
|
||||
|
||||
(defmethod ein:worksheet-save-cells ((ws ein:worksheet))
|
||||
(defmethod ein:worksheet-save-cells ((ws ein:worksheet) &optional deactivate)
|
||||
"Save cells in worksheet buffer in cache before killing the buffer.
|
||||
|
||||
.. warning:: After calling this function, cells in worksheet
|
||||
cannot be used. Use only just before killing the buffer.
|
||||
.. warning:: After called with non-nil DEACTIVATE flag is given,
|
||||
cells in worksheet cannot be used anymore. Use only just
|
||||
before killing the buffer.
|
||||
|
||||
Do nothing when the worksheet WS has no buffer."
|
||||
(when (ein:worksheet-has-buffer-p ws)
|
||||
(let ((cells (ein:worksheet-get-cells ws)))
|
||||
(mapc #'ein:cell-save-text cells)
|
||||
(mapc #'ein:cell-deactivate cells)
|
||||
(when deactivate
|
||||
(mapc #'ein:cell-deactivate cells))
|
||||
(oset ws :saved-cells cells))))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue