mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 23:41:38 -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"
|
:initform "idle"
|
||||||
:documentation "The current state of the kernel. Can be
|
:documentation "The current state of the kernel. Can be
|
||||||
either \"idle\", \"busy\", or \"starting\".")
|
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
|
(requests
|
||||||
:type hash-table
|
:type hash-table
|
||||||
:initform (make-hash-table :test 'equal)
|
: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))
|
(declare (indent 1))
|
||||||
nil)
|
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)
|
(cl-defgeneric jupyter-handle-execute-result ((_client jupyter-kernel-client)
|
||||||
_req
|
_req
|
||||||
_execution-count
|
_execution-count
|
||||||
|
|
|
@ -276,14 +276,12 @@ to."
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(insert (org-element-normalize-string (plist-get pl :text))))))
|
(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)
|
(req jupyter-org-request)
|
||||||
status
|
status
|
||||||
execution-count
|
_execution-count
|
||||||
_user-expressions
|
_user-expressions
|
||||||
payload)
|
payload)
|
||||||
;; TODO: Re-use the REPL's handler somehow?
|
|
||||||
(oset client execution-count (1+ execution-count))
|
|
||||||
(when payload
|
(when payload
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (jupyter-org-request-marker req))
|
(goto-char (jupyter-org-request-marker req))
|
||||||
|
|
|
@ -130,11 +130,7 @@ timeout, the built-in is-complete handler is used."
|
||||||
:initform nil
|
:initform nil
|
||||||
:documentation "Whether or not we should wait to clear the
|
:documentation "Whether or not we should wait to clear the
|
||||||
current output of the cell. Set when the kernel sends a
|
current output of the cell. Set when the kernel sends a
|
||||||
`:clear-output' message.")
|
`:clear-output' message.")))
|
||||||
(execution-count
|
|
||||||
:type integer
|
|
||||||
:initform 1
|
|
||||||
:documentation "The current execution count of the kernel.")))
|
|
||||||
|
|
||||||
(defvar-local jupyter-repl-lang-buffer nil
|
(defvar-local jupyter-repl-lang-buffer nil
|
||||||
"A buffer with the `major-mode' set to the REPL language's `major-mode'.")
|
"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)
|
(cl-defmethod jupyter-handle-execute-reply ((client jupyter-repl-client)
|
||||||
_req
|
_req
|
||||||
_status
|
_status
|
||||||
execution-count
|
_execution-count
|
||||||
_user-expressions
|
_user-expressions
|
||||||
payload)
|
payload)
|
||||||
(oset client execution-count (1+ execution-count))
|
|
||||||
(jupyter-with-repl-buffer client
|
(jupyter-with-repl-buffer client
|
||||||
(when payload
|
(when payload
|
||||||
(jupyter-handle-payload payload))))
|
(jupyter-handle-payload payload))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue