mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Rename s/data-type/parser/g
This commit is contained in:
parent
5a65aba368
commit
f6bcb438e8
2 changed files with 16 additions and 10 deletions
|
@ -80,7 +80,7 @@
|
||||||
(ein:query-ajax
|
(ein:query-ajax
|
||||||
(ein:notebooklist-url url-or-port)
|
(ein:notebooklist-url url-or-port)
|
||||||
:cache nil
|
:cache nil
|
||||||
:data-type #'ein:json-read
|
:parser #'ein:json-read
|
||||||
:success (cons success url-or-port)
|
:success (cons success url-or-port)
|
||||||
:timeout 5000))
|
:timeout 5000))
|
||||||
(ein:notebooklist-get-buffer url-or-port))
|
(ein:notebooklist-get-buffer url-or-port))
|
||||||
|
@ -126,8 +126,8 @@
|
||||||
(unless (setq url-or-port (ein:$notebooklist-url-or-port ein:notebooklist)))
|
(unless (setq url-or-port (ein:$notebooklist-url-or-port ein:notebooklist)))
|
||||||
(ein:query-ajax
|
(ein:query-ajax
|
||||||
(ein:notebooklist-new-url url-or-port)
|
(ein:notebooklist-new-url url-or-port)
|
||||||
:data-type (lambda ()
|
:parser (lambda ()
|
||||||
(ein:notebooklist-get-data-in-body-tag "data-notebook-id"))
|
(ein:notebooklist-get-data-in-body-tag "data-notebook-id"))
|
||||||
:success (cons #'ein:notebooklist-new-notebook-callback (current-buffer))
|
:success (cons #'ein:notebooklist-new-notebook-callback (current-buffer))
|
||||||
:timeout 5000))
|
:timeout 5000))
|
||||||
|
|
||||||
|
|
20
ein-query.el
20
ein-query.el
|
@ -47,7 +47,7 @@
|
||||||
(cache t)
|
(cache t)
|
||||||
(type "GET")
|
(type "GET")
|
||||||
(data nil)
|
(data nil)
|
||||||
(data-type nil)
|
(parser nil)
|
||||||
(headers nil)
|
(headers nil)
|
||||||
(success nil)
|
(success nil)
|
||||||
(error nil)
|
(error nil)
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
:CACHE (nil/t) : append time-stamp to URL so the URL is always loaded.
|
:CACHE (nil/t) : append time-stamp to URL so the URL is always loaded.
|
||||||
:TYPE (string) : sets `url-request-method'
|
:TYPE (string) : sets `url-request-method'
|
||||||
:DATA (string) : sets `url-request-data'
|
:DATA (string) : sets `url-request-data'
|
||||||
:DATA-TYPE (symbol) : a function that reads current buffer and return data
|
:PARSER (symbol) : a function that reads current buffer and return data
|
||||||
:HEADERS (alist) : sets `url-request-extra-headers'
|
:HEADERS (alist) : sets `url-request-extra-headers'
|
||||||
:SUCCESS (cons) : called on success
|
:SUCCESS (cons) : called on success
|
||||||
:ERROR (cons) : called on error
|
:ERROR (cons) : called on error
|
||||||
|
@ -86,7 +86,7 @@ arguments to be passed, depending on situation.
|
||||||
* :SUCCESS callback
|
* :SUCCESS callback
|
||||||
|
|
||||||
This callback takes :DATA (object), which is a data object parsed
|
This callback takes :DATA (object), which is a data object parsed
|
||||||
by :DATA-TYPE. If :DATA-TYPE is not specified, this is nil.
|
by :PARSER. If :PARSER is not specified, this is nil.
|
||||||
The :SUCCESS callback also takes the :STATUS and :RESPONSE-STATUS
|
The :SUCCESS callback also takes the :STATUS and :RESPONSE-STATUS
|
||||||
argument.
|
argument.
|
||||||
|
|
||||||
|
@ -96,6 +96,12 @@ Each value of this alist is a callback which is similar to :ERROR
|
||||||
or :SUCCESS callback. However, current buffer of this callback
|
or :SUCCESS callback. However, current buffer of this callback
|
||||||
is not guaranteed to be the process buffer.
|
is not guaranteed to be the process buffer.
|
||||||
|
|
||||||
|
* :PARSER function
|
||||||
|
|
||||||
|
This is analogous to the `dataType' argument of `$.ajax'.
|
||||||
|
Only this function can accuses to the process buffer, which
|
||||||
|
is killed immediately after the execution of this function.
|
||||||
|
|
||||||
* 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
|
||||||
|
@ -116,7 +122,7 @@ is not guaranteed to be the process buffer.
|
||||||
|
|
||||||
(defun* ein:query-ajax-callback (status &key
|
(defun* ein:query-ajax-callback (status &key
|
||||||
(headers nil)
|
(headers nil)
|
||||||
(data-type nil)
|
(parser nil)
|
||||||
(success nil)
|
(success nil)
|
||||||
(error nil)
|
(error nil)
|
||||||
(timeout nil)
|
(timeout nil)
|
||||||
|
@ -130,13 +136,13 @@ is not guaranteed to be the process buffer.
|
||||||
(ein:log 'debug "(buffer-string) =\n%s" (buffer-string))
|
(ein:log 'debug "(buffer-string) =\n%s" (buffer-string))
|
||||||
|
|
||||||
(ein:query-ajax-cancel-timer)
|
(ein:query-ajax-cancel-timer)
|
||||||
(let* ((buffer (current-buffer)) ; `data-type' could change buffer...
|
(let* ((buffer (current-buffer)) ; `parser' could change buffer...
|
||||||
(response-status url-http-response-status)
|
(response-status url-http-response-status)
|
||||||
(status-code-callback (cdr (assq response-status status-code)))
|
(status-code-callback (cdr (assq response-status status-code)))
|
||||||
(status-error (plist-get status :error))
|
(status-error (plist-get status :error))
|
||||||
(data (if (and data-type (not status-error))
|
(data (if (and parser (not status-error))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(funcall data-type)
|
(funcall parser)
|
||||||
(kill-buffer buffer)))))
|
(kill-buffer buffer)))))
|
||||||
|
|
||||||
(ein:log 'debug "Executing success/error callback.")
|
(ein:log 'debug "Executing success/error callback.")
|
||||||
|
|
Loading…
Add table
Reference in a new issue