As this command requires to invoke multi-line python code, ein.py is
added to store python code needed for EIN. The sys.path is added
automatically when the kernel is started so that any function can be
called as ``__import__("ein").FUNCTION()``. This way, namespace is
not contaminated at all.
Another possible way to implement this is to use user_expressions.
However, replied message is Python's repr. As there is no reliable
way to convert it except using Python itself, I am using stream to
get CWD.
This solves the problem due to the url-retrieve gotcha.
Main changes:
* Separation of the function to parse buffer and callback.
This is good because parsed data can be used from multiple
callbacks (SUCCESS and STATUS-CODE).
* As a result, current buffer for callbacks is not process
buffer anymore. Callbacks should not assume any particular
current buffer.
* RESPONSE-STATUS is added to the arguments for callbacks
to pass around the value of url-http-response-status.
Previous attempts:
* cb5f53c183:
Simpler and better fix than the previous one
* fff269fc39:
ein:notebooklist-delete-notebook works again
Previous fix ignores callbacks even if it is specified if the buffer
is killed. This is simply wrong. As the user of :STATUS-CODE
callback does not touch current buffer, I change the spec.
The bug was in ein:query-ajax-callback. When url-retrieve called in
its callback (which is the case of ein:notebooklist-delete-notebook),
same process buffer is reused. Therefore, old code killed another
buffer (namely notebook list buffer) by accident and the variable
url-http-response-status was void because it is outside of the process
buffer (I am not sure about this part). Current workaround is to
check if the buffer is live before executing buffer, using new macro
ein:with-live-buffer.