Refactor jupyter-repl-eval-file for readability

This commit is contained in:
Nathaniel Nicandro 2018-08-26 15:47:49 -05:00
parent 83fb582270
commit e94db94851

View file

@ -1787,14 +1787,14 @@ are displayed."
(message "Evaluating %s..." file) (message "Evaluating %s..." file)
(setq file (expand-file-name file)) (setq file (expand-file-name file))
(if (file-exists-p file) (if (file-exists-p file)
(let ((buf (find-buffer-visiting file))) (let* ((buf (find-buffer-visiting file))
(jupyter-repl-eval-string (killp (null buf)))
(if buf (with-current-buffer buf (when (null buf)
(buffer-string)) (setq buf (delay-mode-hooks (find-file-noselect file))))
(with-current-buffer (delay-mode-hooks (find-file-noselect file)) (with-current-buffer buf
(prog1 (buffer-string) (jupyter-repl-eval-string (buffer-string) 'silently))
(kill-buffer)))) (when killp
'silently)) (kill-buffer)))
(error "Not a file (%s)" file))) (error "Not a file (%s)" file)))
(defun jupyter-repl-eval-region (beg end &optional silently) (defun jupyter-repl-eval-region (beg end &optional silently)