Move jupyter--received-message-types to jupyter-messages.el

Also fix naming issue, previously `recieved` when it should have been `received`.
This commit is contained in:
Nathaniel Nicandro 2017-12-15 18:16:53 -06:00
parent b4f0c94906
commit ad53e098f6
2 changed files with 25 additions and 27 deletions

View file

@ -238,32 +238,6 @@ for more details."
;;; Processing received messages
;; TODO: Override `jupyter-kernel-client' to hook into receiving these
;; messages. How would an `ob-jupyter' client do this?
(defconst jupyter--recieved-message-types
(list 'execute-result "execute_result"
'execute-reply "execute_reply"
'inspect-reply "inspect_reply"
'complete-reply "complete_reply"
'history-reply "history_reply"
'is-complete-reply "is_complete_reply"
'comm-info-reply "comm_info_reply"
'kernel-info-reply "kernel_info_reply"
'shutdown-reply "shutdown_reply"
'interrupt-reply "interrupt_reply"
'stream "stream"
'display-data "display_data"
'update-display-data "update_display_data"
'execute-input "execute_input"
'error "error"
'status "status"
'clear-output "clear_output"
'input-reply "input_reply")
"A plist mapping symbols to received message types.
This is used to give some type of protection against invalid
message types in `jupyter-add-receive-callback'. If the MSG-TYPE
argument does not match one of the keys in this plist, an error
is thrown.")
(defun jupyter-add-receive-callback (client msg-type msg-id function)
"Add FUNCTION to run when receiving a message reply.
@ -283,7 +257,7 @@ Note that the callback is given the raw decoded message received
from the kernel without any processing done to it."
(declare (indent 3))
(cl-check-type client jupyter-kernel-client)
(let ((mt (plist-get jupyter--recieved-message-types msg-type)))
(let ((mt (plist-get jupyter--received-message-types msg-type)))
(if mt (setq msg-type mt)
(error "Not a valid message type (`%s')" msg-type)))
(let* ((message-callbacks (oref client message-callbacks))

View file

@ -5,6 +5,30 @@
(defconst jupyter-protocol-version "5.3")
(defconst jupyter-message-delimiter "<IDS|MSG>")
(defconst jupyter--false :json-false)
(defconst jupyter--received-message-types
(list 'execute-result "execute_result"
'execute-reply "execute_reply"
'inspect-reply "inspect_reply"
'complete-reply "complete_reply"
'history-reply "history_reply"
'is-complete-reply "is_complete_reply"
'comm-info-reply "comm_info_reply"
'kernel-info-reply "kernel_info_reply"
'shutdown-reply "shutdown_reply"
'interrupt-reply "interrupt_reply"
'stream "stream"
'display-data "display_data"
'update-display-data "update_display_data"
'execute-input "execute_input"
'error "error"
'status "status"
'clear-output "clear_output"
'input-reply "input_reply")
"A plist mapping symbols to received message types.
This is used to give some protection against invalid message
types in `jupyter-add-receive-callback'. If the MSG-TYPE argument
of `jupyter-add-receive-callback' does not match one of the keys
in this plist, an error is thrown.")
;;; Session object