Move jupyter-eval from jupyter-repl.el to jupyter-client.el

This commit is contained in:
Nathaniel Nicandro 2018-10-23 20:45:25 -05:00
parent ab44407fdf
commit ecd6a3098b
2 changed files with 16 additions and 15 deletions

View file

@ -1019,6 +1019,22 @@ the user. Otherwise `read-from-minibuffer' is used."
implementation_version language_info
banner help_links)))))
;;; Evaluation
(defun jupyter-eval (code &optional mime)
"Send an execute request for CODE, wait for the execute result.
The `jupyter-current-client' is used to send the execute request.
All client handlers except the status handler are inhibited for
the request. In addition, the history of the request is not
stored. Return the MIME representation of the result. If MIME is
nil, return the text/plain representation."
(let ((msg (jupyter-wait-until-received :execute-result
(let ((jupyter-inhibit-handlers '(not :status)))
(jupyter-send-execute-request jupyter-current-client
:code code :store-history nil)))))
(when msg
(jupyter-message-data msg (or mime :text/plain)))))
(cl-defgeneric jupyter-send-execute-request ((client jupyter-kernel-client)
&key code
(silent nil)

View file

@ -2132,21 +2132,6 @@ DETAIL is the detail level to use for the request and defaults to
read-expression-map
nil 'jupyter-repl-eval-expression-history)))))
;; Simple eval
(defun jupyter-eval (code &optional mime)
"Send an execute request for CODE, wait for the execute result.
The `jupyter-current-client' is used to send the execute request.
All client handlers except the status handler are inhibited for
the request. In addition, the history of the request is not
stored. Return the MIME representation of the result. If MIME is
nil, return the text/plain representation."
(let ((msg (jupyter-wait-until-received :execute-result
(let ((jupyter-inhibit-handlers '(not :status)))
(jupyter-send-execute-request jupyter-current-client
:code code :store-history nil)))))
(when msg
(jupyter-message-data msg (or mime :text/plain)))))
(defun jupyter-repl-eval-string (str &optional silently cb)
"Evaluate STR with the `jupyter-current-client's REPL.
Replaces the contents of the last cell in the REPL buffer with