all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Felipe Lema <felipelema@mortemale.org>
To: emacs-orgmode@gnu.org
Subject: Report error in scheme evaluation
Date: Tue, 21 Dec 2021 16:58:52 -0300	[thread overview]
Message-ID: <4237997.1UI0SyaRfJ@felipe-thinkpad-x200> (raw)

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

Sup, y'all

I started using guile with Org Babel and I was a little confused that errors weren't being reported. The attached patch will report the error the same way as python evaluation does.

Actually, most of the code was taken from ob-python.el

Let me know if I'm missing anything so this can be merged. It is correct to report errors this way, right?

Felipe

[-- Attachment #2: org-babel-scheme-show-error-in-buffer.diff --]
[-- Type: text/x-patch, Size: 2027 bytes --]

report error in scheme dialect evaluation to user

* ob-scheme.el (org-babel-scheme-execute-with-geiser): paste error into `org-babel-error-buffer-name` and setup buffer to compilation-mode

diff --git a/lisp/org/ob-scheme.el b/lisp/org/ob-scheme.el
index f4836b23fe..2828464bb5 100644
--- a/lisp/org/ob-scheme.el
+++ b/lisp/org/ob-scheme.el
@@ -58,6 +58,7 @@ geiser-repl-window-allow-split
 (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))

 (defcustom org-babel-scheme-null-to 'hline
   "Replace `null' and empty lists in scheme tables with this before returning."
@@ -180,8 +181,20 @@ org-babel-scheme-execute-with-geiser
 	      (setq result (if output
 			       (or (geiser-eval--retort-output ret)
 				   "Geiser Interpreter produced no output")
-			     (geiser-eval--retort-result-str ret "")))))
-	  (when (not repl)
+			     (geiser-eval--retort-result-str ret "")))
+              (when-let* ((err (geiser-eval--retort-error ret)))
+                ;; there was an error, report it!
+                (org-babel-eval-error-notify
+                 -1 ;; filler value, anything non-zero should do
+                 (geiser-eval--retort-output ret))
+                (save-excursion
+                  (when (get-buffer org-babel-error-buffer-name)
+                    (with-current-buffer org-babel-error-buffer-name
+                      (unless (derived-mode-p 'compilation-mode)
+                        (compilation-mode))
+                      ;; Compilation-mode enforces read-only, but Babel expects the buffer modifiable.
+                      (setq buffer-read-only nil)))))))
+          (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)

             reply	other threads:[~2021-12-21 19:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 19:58 Felipe Lema [this message]
2021-12-21 23:07 ` Report error in scheme evaluation Rudolf Adamkovič
2021-12-22  5:27   ` Felipe Lema
2021-12-23 21:01     ` Rudolf Adamkovič
2021-12-22 14:54 ` Ihor Radchenko
2021-12-22 16:56   ` Felipe Lema
2021-12-22 14:58 ` Ihor Radchenko
2021-12-22 16:34 ` Max Nikulin
2021-12-22 17:04   ` Ihor Radchenko
2022-09-12 11:27 ` Ihor Radchenko
  -- strict thread matches above, loose matches on Subject: below --
2021-12-28  1:03 Felipe Lema
2022-04-30  8:11 ` Ihor Radchenko
2022-04-30 10:35   ` Neil Jerram
2022-05-04  2:52     ` Felipe Lema

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4237997.1UI0SyaRfJ@felipe-thinkpad-x200 \
    --to=felipelema@mortemale.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.