From 5c0156bedccd57bc107bc7a00d218b49d0d16192 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Tue, 16 Jan 2018 11:25:07 -0600 Subject: [PATCH] Add optional buffer argument to `jupyter-repl--inspect` --- jupyter-repl-client.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/jupyter-repl-client.el b/jupyter-repl-client.el index 0be0e63..5d70fb4 100644 --- a/jupyter-repl-client.el +++ b/jupyter-repl-client.el @@ -1194,7 +1194,15 @@ COMMAND and ARG have the same meaning as the elements of (remove-text-properties 0 (length doc) '(read-only) doc) (when doc (company-doc-buffer doc)))))) -(defun jupyter-repl--inspect (code pos &optional timeout) +(defun jupyter-repl--inspect (code pos &optional buffer timeout) + "Send an inspect request to a Jupyter kernel. +CODE and POS are the code to send and the position within the +code, respectively. TIMEOUT is how long to wait (in seconds) for +the kernel to respond. If the kernel does not respond within +TIMEOUT, return nil. Otherwise if a reply was received within +TIMEOUT, then return either the inspection text or BUFFER after +inserting the inspection text in BUFFER. In both cases, the +inspection text will already be in a form ready for display." (let ((msg (jupyter-wait-until-received :inspect-reply (jupyter-request-inhibit-handlers (jupyter-inspect-request jupyter-repl-current-client @@ -1204,9 +1212,12 @@ COMMAND and ARG have the same meaning as the elements of (cl-destructuring-bind (&key status found data &allow-other-keys) (jupyter-message-content msg) (when (and (equal status "ok") found) - (with-temp-buffer - (jupyter-repl-insert-data data) - (buffer-string))))))) + (if buffer (with-current-buffer buffer + (jupyter-repl-insert-data data) + buffer) + (with-temp-buffer + (jupyter-repl-insert-data data) + (buffer-string)))))))) ;;; `jupyter-repl-mode' (defvar jupyter-repl-mode-map