Detaching buffer from worksheet makes it impossible to close the
worksheet buffer (hence the notebook itself) afterwards.
This can be confirmed by the following two tests introduced in the
commit af989a377b
* ein:notebook-kill-kernel-then-close-when-its-alive
* ein:notebook-kill-kernel-then-close-when-already-dead
See also: d0a16798f4
Now, new `:dont-save-cells' slot is added to `ein:worksheet'.
`ein:worksheet-save-cells' do not save cells when this slot is
non-nil.
Detaching buffer caused problem in the command
ein:notebook-kill-kernel-then-close-command
because after detaching buffer ein:notebook-close
does not work.
The test ein:notebook-to-json-after-closing-a-worksheet fails at this
point.
Fix two bugs in saving notebook.
1. When discarding a worksheet cells in the buffer should not be
cached, so that saving the notebook afterward will note save
the discarded data.
2. After saving a notebook, saved data should be cached so that
discarding a worksheet and saving the notebook will save the
data saved before.
* Cache cell instances instead of data sent from server.
This way, to-json works smoothly as I don't need to implement
plist to alist conversion.
* As a result, theoretically EIN can open notebook with multiple
worksheets now, although it can edit only the first worksheet.
* Worksheet buffer can be closed (provided it is not modified)
while notebook is still open.
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.
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).