mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Fix ein:notebook-close-worksheet
What ein:notebook-close-worksheet did was horribly wrong. It deleted a worksheet. Instead, now it properly close worksheet. The failing test added in the previous commit passes now (ein:notebook-to-json-after-closing-a-worksheet).
This commit is contained in:
parent
6c6fa65ec6
commit
1f8f7dd8c8
2 changed files with 21 additions and 3 deletions
|
@ -215,9 +215,14 @@ Current buffer for these functions is set to the notebook buffer.")
|
|||
call notebook destructor `ein:notebook-del'."
|
||||
(symbol-macrolet ((worksheets (ein:$notebook-worksheets notebook))
|
||||
(scratchsheets (ein:$notebook-scratchsheets notebook)))
|
||||
(setq worksheets (delq ws worksheets))
|
||||
(setq scratchsheets (delq ws scratchsheets))
|
||||
(unless (or worksheets scratchsheets)
|
||||
(cond
|
||||
((ein:worksheet-p ws) (ein:worksheet-save-cells ws))
|
||||
(t (setq scratchsheets (delq ws scratchsheets))))
|
||||
(unless (or (ein:filter (lambda (x)
|
||||
(and (not (eq x ws))
|
||||
(ein:worksheet-has-buffer-p x)))
|
||||
worksheets)
|
||||
scratchsheets)
|
||||
(ein:notebook-del notebook))))
|
||||
|
||||
|
||||
|
|
|
@ -225,6 +225,19 @@ this value."
|
|||
(ein:worksheet-get-cells ws))))
|
||||
`((cells . ,(apply #'vector cells)))))
|
||||
|
||||
(defmethod ein:worksheet-save-cells ((ws ein:worksheet))
|
||||
"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.
|
||||
|
||||
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)
|
||||
(oset ws :saved-cells cells))))
|
||||
|
||||
|
||||
;;; Cell indexing, retrieval, etc.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue