Include scratch sheet in ein:notebook-buffer

Now it is possible to have worksheet buffer closed but scratchsheet
buffer opened.  In this case, ein:notebook-live-p should return t
and ein:notebook-buffer should return the scratchsheet buffer.
This is because notebook commands can such as save or rename can be
executed from the scratchsheet buffer.

ein:notebook-to-json-after-closing-a-worksheet is modified also
this test fails without the change in ein:notebook-buffer.
This commit is contained in:
Takafumi Arakaki 2012-08-29 20:14:55 +02:00
parent 271bb24b3e
commit b56644d9b6
2 changed files with 6 additions and 2 deletions

View file

@ -231,8 +231,11 @@ call notebook destructor `ein:notebook-del'."
(defun ein:notebook-buffer (notebook)
"Return the buffer that is associated with NOTEBOOK."
;; FIXME: Find a better way to define notebook buffer! (or remove this func)
(loop for ws in (ein:$notebook-worksheets notebook)
if (ein:worksheet-buffer ws) return it))
(let ((first-buffer
(lambda (ws-list)
(loop for ws in ws-list if (ein:worksheet-buffer ws) return it))))
(or (funcall first-buffer (ein:$notebook-worksheets notebook))
(funcall first-buffer (ein:$notebook-scratchsheets notebook)))))
(defun ein:notebook-buffer-list (notebook)
"Return the buffers associated with NOTEBOOK's kernel.

View file

@ -729,6 +729,7 @@ defined."
(should-not (ein:notebook-modified-p notebook))
;; Kill a worksheet buffer
(kill-buffer buffer)
(should (ein:notebook-live-p notebook))
;; to-json should still work
(funcall test notebook))))