~bzg/org-mode

f35fb8ac2a811dcdf5bd90d976239130cf0a994a — Marc Nieper-Wißkirchen 30 days ago a6c8829
lisp/ob-scheme.el: Do not hide Scheme evaluation errors

* lisp/ob-eval.el (org-babel-eval-error-notify): Handle an exit code of nil.

* lisp/ob-scheme.el (org-babel-expand-body:scheme)
(org-babel-scheme-get-repl, org-babel-scheme-make-session-name)
(org-babel-scheme-execute-with-geiser)
(org-babel-scheme--table-or-string, org-babel-execute:scheme):
Display Scheme evaluation errors in an error buffer using
`org-babel-eval-error-notify'.

TINYCHANGE
2 files changed, 23 insertions(+), 8 deletions(-)

M lisp/ob-eval.el
M lisp/ob-scheme.el
M lisp/ob-eval.el => lisp/ob-eval.el +8 -3
@@ 37,16 37,21 @@
(declare-function org-babel-temp-file "ob-core" (prefix &optional suffix))

(defun org-babel-eval-error-notify (exit-code stderr)
  "Open a buffer to display STDERR and a message with the value of EXIT-CODE."
  "Open a buffer to display STDERR and a message with the value of EXIT-CODE.
If EXIT-CODE is nil, display the message without a code."
  (let ((buf (get-buffer-create org-babel-error-buffer-name)))
    (with-current-buffer buf
      (goto-char (point-max))
      (save-excursion
        (unless (bolp) (insert "\n"))
        (insert stderr)
        (insert (format "[ Babel evaluation exited with code %S ]" exit-code))))
        (if exit-code
            (insert (format "[ Babel evaluation exited with code %S ]" exit-code))
          (insert "[ Babel evaluation exited abnormally ]"))))
    (display-buffer buf))
  (message "Babel evaluation exited with code %S" exit-code))
  (if exit-code
      (message "Babel evaluation exited with code %S" exit-code)
    (message "Babel evaluation exited abnormally")))

(defun org-babel-eval (command query)
  "Run COMMAND on QUERY.

M lisp/ob-scheme.el => lisp/ob-scheme.el +15 -5
@@ 65,6 65,8 @@
(declare-function geiser-repl-exit "ext:geiser-repl" (&optional arg))
(declare-function geiser-eval--retort-output "ext:geiser-eval" (ret))
(declare-function geiser-eval--retort-result-str "ext:geiser-eval" (ret prefix))
(declare-function geiser-eval--retort-error "ext:geiser-eval" (ret))
(declare-function geiser-eval--retort-error-msg "ext:geiser-eval" (err))

(defcustom org-babel-scheme-null-to 'hline
  "Replace `null' and empty lists in scheme tables with this before returning."


@@ 193,22 195,30 @@ is true; otherwise returns the last value."
                                  #'geiser-eval-region)
                                (point-min)
                                (point-max))))
	      (setq result (if output
	      (let ((err (geiser-eval--retort-error ret)))
		(setq result (cond
			      (output
			       (or (geiser-eval--retort-output ret)
				   "Geiser Interpreter produced no output")
			     (geiser-eval--retort-result-str ret "")))))
				   "Geiser Interpreter produced no output"))
			      (err nil)
			      (t (geiser-eval--retort-result-str ret ""))))
	  (when (not repl)
	    (save-current-buffer (set-buffer repl-buffer)
				 (geiser-repl-exit))
	    (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
	    (kill-buffer repl-buffer)))))
		  (kill-buffer repl-buffer))
		(when err
		  (let ((msg (geiser-eval--error-msg err)))
		    (org-babel-eval-error-notify
		     nil
		     (concat (if (listp msg) (car msg) msg) "\n"))))))))))
    result))

(defun org-babel-scheme--table-or-string (results)
  "Convert RESULTS into an appropriate elisp value.
If the results look like a list or tuple, then convert them into an
Emacs-lisp table, otherwise return the results as a string."
  (let ((res (org-babel-script-escape results)))
  (let ((res (and results (org-babel-script-escape results))))
    (cond ((listp res)
           (mapcar (lambda (el)
		     (if (or (null el) (eq el 'null))