[WIP] Make ob-jupyter unaware of the REPL buffer

Try not to modify the REPL buffer in any way from `ob-jupyter` except for
inserting a code cell.
This commit is contained in:
Nathaniel Nicandro 2018-02-07 17:28:33 -06:00
parent dc7c1e00e8
commit e032285f9a

View file

@ -388,19 +388,18 @@ if RESULTS is a list."
"Execute BODY according to PARAMS. "Execute BODY according to PARAMS.
BODY is the code to execute for the current Jupyter `:session' of BODY is the code to execute for the current Jupyter `:session' of
PARAMS." PARAMS."
(let* ((session (alist-get :session params)) (let* ((repl-buffer (org-babel-jupyter-initiate-session
(repl-buffer (org-babel-jupyter-initiate-session session params)) (alist-get :session params) params))
(kernel-lang (cl-destructuring-bind (&key language_info (client (with-current-buffer repl-buffer
&allow-other-keys) jupyter-repl-current-client))
(oref (with-current-buffer repl-buffer (kernel-lang (plist-get (plist-get (oref client kernel-info)
jupyter-repl-current-client) :language_info)
kernel-info) :name))
(plist-get language_info :language)))
(code (org-babel-expand-body:jupyter (code (org-babel-expand-body:jupyter
body params (org-babel-variable-assignments:jupyter body params (org-babel-variable-assignments:jupyter
params kernel-lang) params kernel-lang)
kernel-lang)) kernel-lang))
(req (with-current-buffer repl-buffer (req (with-jupyter-repl-buffer client
(goto-char (point-max)) (goto-char (point-max))
(jupyter-repl-replace-cell-code code) (jupyter-repl-replace-cell-code code)
;; TODO: Should handlers be inhbited? They are inhibited to ;; TODO: Should handlers be inhbited? They are inhibited to
@ -408,10 +407,8 @@ PARAMS."
;; redirected to the output of a Jupyter src block. It ;; redirected to the output of a Jupyter src block. It
;; doesn't seem to make sense to insert output in the REPL ;; doesn't seem to make sense to insert output in the REPL
;; buffer when it is redirected somewhere else. ;; buffer when it is redirected somewhere else.
(prog1 (let ((jupyter-inhibit-handlers t)) (let ((jupyter-inhibit-handlers t))
(jupyter-execute-request jupyter-repl-current-client)) (jupyter-execute-request jupyter-repl-current-client)))))
(when (get-buffer-window)
(set-window-point (get-buffer-window) (point)))))))
;; Setup callbacks for the request ;; Setup callbacks for the request
(let* ((result-type (alist-get :result-type params)) (let* ((result-type (alist-get :result-type params))
(async (equal (alist-get :async params) "yes")) (async (equal (alist-get :async params) "yes"))