mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Simpler and better fix than the previous one
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.
This commit is contained in:
parent
fff269fc39
commit
cb5f53c183
1 changed files with 17 additions and 11 deletions
28
ein-query.el
28
ein-query.el
|
@ -87,6 +87,12 @@ FUNCTION so it must be fetched from the buffer.
|
||||||
|
|
||||||
The :SUCCESS callback also takes the :STATUS argument.
|
The :SUCCESS callback also takes the :STATUS argument.
|
||||||
|
|
||||||
|
* :STATUS-CODE callback
|
||||||
|
|
||||||
|
Each value of this alist is a callback which is similar to :ERROR
|
||||||
|
or :SUCCESS callback. However, current buffer of this callback
|
||||||
|
is not guaranteed to be the process buffer.
|
||||||
|
|
||||||
* See also: http://api.jquery.com/jQuery.ajax/"
|
* See also: http://api.jquery.com/jQuery.ajax/"
|
||||||
(ein:log 'debug "EIN:QUERY-AJAX")
|
(ein:log 'debug "EIN:QUERY-AJAX")
|
||||||
(unless cache
|
(unless cache
|
||||||
|
@ -113,7 +119,9 @@ The :SUCCESS callback also takes the :STATUS argument.
|
||||||
(status-code nil)
|
(status-code nil)
|
||||||
&allow-other-keys)
|
&allow-other-keys)
|
||||||
(declare (special url-http-response-status))
|
(declare (special url-http-response-status))
|
||||||
(let ((buffer (current-buffer)))
|
(let ((buffer (current-buffer))
|
||||||
|
(status-code-callback
|
||||||
|
(cdr (assq url-http-response-status status-code))))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(ein:log 'debug "EIN:QUERY-AJAX-CALLBACK")
|
(ein:log 'debug "EIN:QUERY-AJAX-CALLBACK")
|
||||||
|
@ -122,16 +130,14 @@ The :SUCCESS callback also takes the :STATUS argument.
|
||||||
url-http-response-status)
|
url-http-response-status)
|
||||||
(ein:log 'debug "(buffer-string) =\n%s" (buffer-string))
|
(ein:log 'debug "(buffer-string) =\n%s" (buffer-string))
|
||||||
|
|
||||||
(ein:with-live-buffer buffer
|
(ein:log 'debug "Executing success/error callback.")
|
||||||
(ein:log 'debug "Executing success/error callback.")
|
(apply #'ein:safe-funcall-packed
|
||||||
(apply #'ein:safe-funcall-packed
|
(if (plist-get status :error)
|
||||||
(if (plist-get status :error)
|
(list error :symbol-status 'error :status status)
|
||||||
(list error :symbol-status 'error :status status)
|
(list success :status status)))
|
||||||
(list success :status status))))
|
|
||||||
(ein:with-live-buffer buffer
|
(ein:log 'debug "Executing status-code callback.")
|
||||||
(ein:log 'debug "Executing status-code callback.")
|
(ein:safe-funcall-packed status-code-callback))
|
||||||
(ein:aif (assq url-http-response-status status-code)
|
|
||||||
(ein:safe-funcall-packed (cdr it)))))
|
|
||||||
(ein:with-live-buffer buffer
|
(ein:with-live-buffer buffer
|
||||||
(ein:query-ajax-cancel-timer))
|
(ein:query-ajax-cancel-timer))
|
||||||
(kill-buffer buffer))))
|
(kill-buffer buffer))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue