mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Remove cell from kernel-execute callbacks
This commit is contained in:
parent
bb56cd4681
commit
93199a392b
4 changed files with 17 additions and 9 deletions
|
@ -93,6 +93,7 @@
|
||||||
(input :initarg :input :type string
|
(input :initarg :input :type string
|
||||||
:documentation "Place to hold data until it is rendered via `ewoc'.")
|
:documentation "Place to hold data until it is rendered via `ewoc'.")
|
||||||
(outputs :initarg :outputs :initform nil :type list)
|
(outputs :initarg :outputs :initform nil :type list)
|
||||||
|
(events :initarg :events :type ein:events)
|
||||||
(cell-id :initarg :cell-id :initform (ein:utils-uuid) :type string))
|
(cell-id :initarg :cell-id :initform (ein:utils-uuid) :type string))
|
||||||
"Notebook cell base class")
|
"Notebook cell base class")
|
||||||
|
|
||||||
|
@ -766,7 +767,7 @@ Called from ewoc pretty printer via `ein:cell-insert-output'."
|
||||||
(list :execute_reply (cons #'ein:cell--handle-execute-reply cell)
|
(list :execute_reply (cons #'ein:cell--handle-execute-reply cell)
|
||||||
:output (cons #'ein:cell--handle-output cell)
|
:output (cons #'ein:cell--handle-output cell)
|
||||||
:clear_output (cons #'ein:cell--handle-clear-output cell)
|
:clear_output (cons #'ein:cell--handle-clear-output cell)
|
||||||
:cell cell)))
|
:set_next_input (cons #'ein:cell--handle-set-next-input cell))))
|
||||||
(apply #'ein:kernel-execute kernel code callbacks args)))
|
(apply #'ein:kernel-execute kernel code callbacks args)))
|
||||||
|
|
||||||
(defmethod ein:cell--handle-execute-reply ((cell ein:codecell) content)
|
(defmethod ein:cell--handle-execute-reply ((cell ein:codecell) content)
|
||||||
|
@ -775,6 +776,10 @@ Called from ewoc pretty printer via `ein:cell-insert-output'."
|
||||||
;; (oset cell :dirty t)
|
;; (oset cell :dirty t)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defmethod ein:cell--handle-set-next-input ((cell ein:codecell) text)
|
||||||
|
(ein:events-trigger
|
||||||
|
(oref cell :events) '(set_next_input . Cell) (list :cell cell :text text)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Output area
|
;;; Output area
|
||||||
|
|
|
@ -317,7 +317,7 @@ When calling this method pass a CALLBACKS structure of the form:
|
||||||
(:execute_reply EXECUTE-REPLY-CALLBACK
|
(:execute_reply EXECUTE-REPLY-CALLBACK
|
||||||
:output OUTPUT-CALLBACK
|
:output OUTPUT-CALLBACK
|
||||||
:clear_output CLEAR-OUTPUT-CALLBACK
|
:clear_output CLEAR-OUTPUT-CALLBACK
|
||||||
:cell CELL)
|
:set_next_input SET-NEXT-INPUT)
|
||||||
|
|
||||||
Objects end with -CALLBACK above must pack a FUNCTION and its
|
Objects end with -CALLBACK above must pack a FUNCTION and its
|
||||||
first ARGUMENT in a `cons':
|
first ARGUMENT in a `cons':
|
||||||
|
@ -345,7 +345,7 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#execute
|
||||||
Output type messages is documented here:
|
Output type messages is documented here:
|
||||||
http://ipython.org/ipython-doc/dev/development/messaging.html#messages-on-the-pub-sub-socket
|
http://ipython.org/ipython-doc/dev/development/messaging.html#messages-on-the-pub-sub-socket
|
||||||
|
|
||||||
The CELL value may be use for the `set_next_input' payload.
|
The SET-NEXT-INPUT callback will be passed the `set_next_input' payload.
|
||||||
|
|
||||||
See `ein:kernel--handle-shell-reply' for how the callbacks are called."
|
See `ein:kernel--handle-shell-reply' for how the callbacks are called."
|
||||||
(assert (ein:kernel-ready-p kernel))
|
(assert (ein:kernel-ready-p kernel))
|
||||||
|
@ -443,9 +443,9 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#complete
|
||||||
(ein:log 'debug "no callback for: msg_type=%s msg_id=%s"
|
(ein:log 'debug "no callback for: msg_type=%s msg_id=%s"
|
||||||
msg-type msg-id))
|
msg-type msg-id))
|
||||||
(ein:aif (plist-get content :payload)
|
(ein:aif (plist-get content :payload)
|
||||||
(ein:kernel--handle-payload kernel (plist-get callbacks :cell) it)))))
|
(ein:kernel--handle-payload kernel callbacks it)))))
|
||||||
|
|
||||||
(defun ein:kernel--handle-payload (kernel cell payload)
|
(defun ein:kernel--handle-payload (kernel callbacks payload)
|
||||||
(loop with events = (ein:$kernel-events kernel)
|
(loop with events = (ein:$kernel-events kernel)
|
||||||
for p in payload
|
for p in payload
|
||||||
for text = (plist-get p :text)
|
for text = (plist-get p :text)
|
||||||
|
@ -456,8 +456,8 @@ http://ipython.org/ipython-doc/dev/development/messaging.html#complete
|
||||||
events '(open_with_text . Pager) (list :text text)))
|
events '(open_with_text . Pager) (list :text text)))
|
||||||
else if
|
else if
|
||||||
(equal source "IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input")
|
(equal source "IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input")
|
||||||
do (ein:events-trigger
|
do (ein:aif (plist-get callbacks :set_next_input)
|
||||||
events '(set_next_input . Cell) (list :cell cell :text text))))
|
(ein:funcall-packed it text))))
|
||||||
|
|
||||||
(defun ein:kernel--handle-iopub-reply (kernel packet)
|
(defun ein:kernel--handle-iopub-reply (kernel packet)
|
||||||
(destructuring-bind
|
(destructuring-bind
|
||||||
|
|
|
@ -304,7 +304,10 @@ the time of execution."
|
||||||
;; Note: TYPE can be a string.
|
;; Note: TYPE can be a string.
|
||||||
;; FIXME: unify type of TYPE to symbol or string.
|
;; FIXME: unify type of TYPE to symbol or string.
|
||||||
(apply #'ein:cell-from-type
|
(apply #'ein:cell-from-type
|
||||||
(format "%s" type) :ewoc (ein:$notebook-ewoc notebook) args))
|
(format "%s" type)
|
||||||
|
:ewoc (ein:$notebook-ewoc notebook)
|
||||||
|
:events (ein:$notebook-events notebook)
|
||||||
|
args))
|
||||||
|
|
||||||
(defun ein:notebook-get-cells (notebook)
|
(defun ein:notebook-get-cells (notebook)
|
||||||
(let* ((ewoc (ein:$notebook-ewoc notebook))
|
(let* ((ewoc (ein:$notebook-ewoc notebook))
|
||||||
|
|
|
@ -335,7 +335,7 @@ some text
|
||||||
(list :execute_reply (cons #'ein:cell--handle-execute-reply cell)
|
(list :execute_reply (cons #'ein:cell--handle-execute-reply cell)
|
||||||
:output (cons #'ein:cell--handle-output cell)
|
:output (cons #'ein:cell--handle-output cell)
|
||||||
:clear_output (cons #'ein:cell--handle-clear-output cell)
|
:clear_output (cons #'ein:cell--handle-clear-output cell)
|
||||||
:cell cell)))
|
:set_next_input (cons #'ein:cell--handle-set-next-input cell))))
|
||||||
(should (ein:$kernel-p kernel))
|
(should (ein:$kernel-p kernel))
|
||||||
(should (ein:codecell-p cell))
|
(should (ein:codecell-p cell))
|
||||||
(should (ein:$kernel-p (oref cell :kernel)))
|
(should (ein:$kernel-p (oref cell :kernel)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue