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).
Complex backward dependency on notebook module in worksheet module
is removed. ein:worksheet class depends on ein:notebook through
simple callbacks.
* There is no object holding notification instance in a slot.
Worksheet is loosely coupled with notification via buffer
and events handler.
* ein:notebook-discard-output-on-save is obsolete now.
What notification module needs to know is its buffer and the events
handler. So there is no reason to keep it in the worksheet slot.
Besides, setting header-line-format before calling notebook-mode
is not good because setting major mode discards header-line-format.
So, notification is setup in notebook module now.