From ecd6a3098bfaeca75386243f7998a267e51a153a Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Tue, 23 Oct 2018 20:45:25 -0500 Subject: [PATCH] Move `jupyter-eval` from `jupyter-repl.el` to `jupyter-client.el` --- jupyter-client.el | 16 ++++++++++++++++ jupyter-repl.el | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/jupyter-client.el b/jupyter-client.el index e02da63..89f6b7e 100644 --- a/jupyter-client.el +++ b/jupyter-client.el @@ -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) diff --git a/jupyter-repl.el b/jupyter-repl.el index 32d2401..cd8c2fd 100644 --- a/jupyter-repl.el +++ b/jupyter-repl.el @@ -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