mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Change the spec of callbacks: msg-type is str now
Test ein:notebook-execute-current-cell is passed. At this point all unit tests in test/test-ein-*.el are passed. msg-type was first a string and I changed it to a keyword when I am writing ein:kernel-execute. But as I need to fix a lot of other places, I change it back to a string. Note that msg-type can come from JSON directly when the notebook is first opened, so it must be consistent with that routines. Maybe I will change it again, but at that time, symbol is better than keyword because msg-type is a value rather than a key.
This commit is contained in:
parent
676e4ff523
commit
3985f97eb8
2 changed files with 14 additions and 15 deletions
10
ein-cell.el
10
ein-cell.el
|
@ -754,16 +754,16 @@ Called from ewoc pretty printer via `ein:cell-insert-output'."
|
|||
|
||||
(defmethod ein:cell--handle-output ((cell ein:codecell) msg-type content)
|
||||
(let* ((json (list :output_type msg-type)))
|
||||
(case msg-type
|
||||
(:stream
|
||||
(ein:case-equal msg-type
|
||||
(("stream")
|
||||
(plist-put json :text (plist-get content :data))
|
||||
(plist-put json :stream (plist-get content :name)))
|
||||
((:display_data :pyout)
|
||||
(when (eql msg-type :pyout)
|
||||
(("display_data" "pyout")
|
||||
(when (equal msg-type "pyout")
|
||||
(plist-put json :prompt_number (plist-get content :execution_count)))
|
||||
(setq json (ein:output-area-convert-mime-types
|
||||
json (plist-get content :data))))
|
||||
(:pyerr
|
||||
(("pyerr")
|
||||
(plist-put json :ename (plist-get content :ename))
|
||||
(plist-put json :evalue (plist-get content :evalue))
|
||||
(plist-put json :traceback (plist-get content :traceback))))
|
||||
|
|
|
@ -302,8 +302,7 @@ For example, the EXECUTE-REPLY-CALLBACK is called as:
|
|||
(`funcall' FUNCTION ARGUMENT CONTENT)
|
||||
|
||||
.. [#output] One of `stream', `display_data', `pyout', `pyerr'.
|
||||
.. [#output2] The argument MSG-ID for the FUNCTION is `keyword'.
|
||||
(e.g., `:stream')
|
||||
.. [#output2] The argument MSG-ID for the FUNCTION is a string.
|
||||
.. [#clear]_ Content object has `stdout', `stderr' and `other'
|
||||
fields that are booleans.
|
||||
|
||||
|
@ -400,10 +399,10 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#complete
|
|||
(destructuring-bind
|
||||
(&key header content parent_header &allow-other-keys)
|
||||
(ein:json-read-from-string packet)
|
||||
(let* ((msg-type (intern (format ":%s" (plist-get header :msg_type))))
|
||||
(let* ((msg-type (plist-get header :msg_type))
|
||||
(msg-id (plist-get parent_header :msg_id))
|
||||
(callbacks (ein:kernel-get-callbacks-for-msg kernel msg-id))
|
||||
(cb (plist-get callbacks msg-type)))
|
||||
(cb (plist-get callbacks (intern (format ":%s" msg-type)))))
|
||||
(if cb
|
||||
(ein:funcall-packed cb content)
|
||||
(ein:log 'debug "no callback for: msg_type=%s msg_id=%s"
|
||||
|
@ -429,18 +428,18 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#complete
|
|||
(destructuring-bind
|
||||
(&key content parent_header header &allow-other-keys)
|
||||
(ein:json-read-from-string packet)
|
||||
(let* ((msg-type (intern (format ":%s" (plist-get header :msg_type))))
|
||||
(let* ((msg-type (plist-get header :msg_type))
|
||||
(callbacks (ein:kernel-get-callbacks-for-msg
|
||||
kernel (plist-get parent_header :msg_id)))
|
||||
(events (ein:$kernel-events kernel)))
|
||||
(ein:log 'debug "HANDLE-IOPUB-REPLY: msg_type = %s" msg-type)
|
||||
(if (and (not (eql msg-type :status)) (null callbacks))
|
||||
(if (and (not (equal msg-type "status")) (null callbacks))
|
||||
(ein:log 'verbose "Got message not from this kernel.")
|
||||
(case msg-type
|
||||
((:stream :display_data :pyout :pyerr)
|
||||
(ein:case-equal msg-type
|
||||
(("stream" "display_data" "pyout" "pyerr")
|
||||
(ein:aif (plist-get callbacks :output)
|
||||
(ein:funcall-packed it msg-type content)))
|
||||
(:status
|
||||
(("status")
|
||||
(ein:case-equal (plist-get content :execution_state)
|
||||
(("busy")
|
||||
(ein:events-trigger events '(status_busy . Kernel)))
|
||||
|
@ -449,7 +448,7 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#complete
|
|||
(("dead")
|
||||
(ein:kernel-stop-channels kernel)
|
||||
(ein:events-trigger events '(status_dead . Kernel)))))
|
||||
(:clear_output
|
||||
(("clear_output")
|
||||
(ein:aif (plist-get callbacks :clear_output)
|
||||
(ein:funcall-packed it content))))))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue