Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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.
  • Loading branch information...
1 parent 676e4ff commit 3985f97eb856bf35271cc087434796d3b6a2dd7b @tkf committed
Showing with 14 additions and 15 deletions.
  1. +5 −5 ein-cell.el
  2. +9 −10 ein-kernel.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))))
19 ein-kernel.el
@@ -302,8 +302,7 @@ For example, the EXECUTE-REPLY-CALLBACK is called as:
.. [#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 @@
(&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 @@
(&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)
(ein:events-trigger events '(status_busy . Kernel)))
@@ -449,7 +448,7 @@
(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))))))))

0 comments on commit 3985f97

Please sign in to comment.
Something went wrong with that request. Please try again.