The code for resetting process-query-on-exit-flag is not executed and
it works fine without it. I think this flag was reset in the old
version because the buffer is killed in the query callback.
1. `process-query-on-exit-flag' reset does not work because
`kill-buffer' is called in the callback.
2. data is set to the value of which `kill-buffer' is returned.
3. ein:query-ajax-timeout is used after the buffer is killed.
4. `kill-buffer' was called twice. As delete-buffer calls the
callback which kill buffer, killing buffer in the timeout
callback is not needed.
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.
There was two bugs:
* Process buffer was killed in ein:notebooklist-url-retrieve-callback
where should be handled by ein:query-ajax-callback. There was two
calls of kill-buffer. This is why the list buffer was killed.
* At the time ein:query-ajax-cancel-timer is called in
ein:query-ajax-callback the current buffer was changed because
pop-to-buffer is called in the callback. Wrapping callbacks
with save-current-buffer fixes the problem.