From 473a16a0a7c6155f5747d0f915e0d3621b738af8 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 30 Aug 2012 02:42:49 +0200 Subject: [PATCH] Save cells in ein:notebook-save-notebook-success --- lisp/ein-notebook.el | 6 ++++-- lisp/ein-worksheet.el | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ein-notebook.el b/lisp/ein-notebook.el index acfecb7..97a7228 100644 --- a/lisp/ein-notebook.el +++ b/lisp/ein-notebook.el @@ -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)) diff --git a/lisp/ein-worksheet.el b/lisp/ein-worksheet.el index 6d40db3..27348f8 100644 --- a/lisp/ein-worksheet.el +++ b/lisp/ein-worksheet.el @@ -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))))