mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-04 15:41:37 -05:00
Add execution-count slot to a jupyter-kernel-client
This allows the default `jupyter-kernel-client' implementation to do the work of updating the execution count instead of having subclasses track it.
This commit is contained in:
parent
0c92afea26
commit
6b7ecfcf08
3 changed files with 17 additions and 11 deletions
|
@ -95,6 +95,12 @@ client's ioloop slot.")
|
|||
:initform "idle"
|
||||
:documentation "The current state of the kernel. Can be
|
||||
either \"idle\", \"busy\", or \"starting\".")
|
||||
(execution-count
|
||||
:type integer
|
||||
:initform 1
|
||||
:documentation "The *next* execution count of the kernel.
|
||||
I.e., the execution count that will be assigned to the
|
||||
next :execute-request sent to the kernel.")
|
||||
(requests
|
||||
:type hash-table
|
||||
:initform (make-hash-table :test 'equal)
|
||||
|
@ -1907,6 +1913,13 @@ If RESTART is non-nil, request a restart instead of a complete shutdown."
|
|||
(declare (indent 1))
|
||||
nil)
|
||||
|
||||
(cl-defmethod jupyter-handle-execute-input :before ((client jupyter-kernel-client)
|
||||
_req
|
||||
_code
|
||||
execution-count)
|
||||
"Set CLIENT's execution-count slot to 1 + EXECUTION-COUNT."
|
||||
(oset client execution-count (1+ execution-count)))
|
||||
|
||||
(cl-defgeneric jupyter-handle-execute-result ((_client jupyter-kernel-client)
|
||||
_req
|
||||
_execution-count
|
||||
|
|
|
@ -276,14 +276,12 @@ to."
|
|||
(forward-line)
|
||||
(insert (org-element-normalize-string (plist-get pl :text))))))
|
||||
|
||||
(cl-defmethod jupyter-handle-execute-reply ((client jupyter-org-client)
|
||||
(cl-defmethod jupyter-handle-execute-reply ((_client jupyter-org-client)
|
||||
(req jupyter-org-request)
|
||||
status
|
||||
execution-count
|
||||
_execution-count
|
||||
_user-expressions
|
||||
payload)
|
||||
;; TODO: Re-use the REPL's handler somehow?
|
||||
(oset client execution-count (1+ execution-count))
|
||||
(when payload
|
||||
(save-excursion
|
||||
(goto-char (jupyter-org-request-marker req))
|
||||
|
|
|
@ -130,11 +130,7 @@ timeout, the built-in is-complete handler is used."
|
|||
:initform nil
|
||||
:documentation "Whether or not we should wait to clear the
|
||||
current output of the cell. Set when the kernel sends a
|
||||
`:clear-output' message.")
|
||||
(execution-count
|
||||
:type integer
|
||||
:initform 1
|
||||
:documentation "The current execution count of the kernel.")))
|
||||
`:clear-output' message.")))
|
||||
|
||||
(defvar-local jupyter-repl-lang-buffer nil
|
||||
"A buffer with the `major-mode' set to the REPL language's `major-mode'.")
|
||||
|
@ -738,10 +734,9 @@ lines, truncate it to something less than
|
|||
(cl-defmethod jupyter-handle-execute-reply ((client jupyter-repl-client)
|
||||
_req
|
||||
_status
|
||||
execution-count
|
||||
_execution-count
|
||||
_user-expressions
|
||||
payload)
|
||||
(oset client execution-count (1+ execution-count))
|
||||
(jupyter-with-repl-buffer client
|
||||
(when payload
|
||||
(jupyter-handle-payload payload))))
|
||||
|
|
Loading…
Add table
Reference in a new issue