all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Report error in scheme evaluation
@ 2021-12-21 19:58 Felipe Lema
  2021-12-21 23:07 ` Rudolf Adamkovič
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Felipe Lema @ 2021-12-21 19:58 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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)

^ permalink raw reply related	[flat|nested] 14+ messages in thread
* Re: Report error in scheme evaluation
@ 2021-12-28  1:03 Felipe Lema
  2022-04-30  8:11 ` Ihor Radchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Lema @ 2021-12-28  1:03 UTC (permalink / raw)
  To: yantar92, emacs-orgmode

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

I just realized I was un-CCed out of the thread

Here's the updated patch with the requested changes (actually single one)

Lemme know if I'm missing anything else.

Felipe

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

diff --git a/lisp/org/ob-scheme.el b/lisp/org/ob-scheme.el
index f4836b23fe..8720bd099e 100644
--- a/lisp/org/ob-scheme.el
+++ b/lisp/org/ob-scheme.el
@@ -39,6 +39,7 @@
 
 ;;; Code:
 (require 'ob)
+(require 'subr-x)
 (require 'geiser nil t)
 (require 'geiser-impl nil t)
 (defvar geiser-repl--repl)             ; Defined in geiser-repl.el
@@ -58,6 +59,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 +182,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)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-09-12 11:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-21 19:58 Report error in scheme evaluation Felipe Lema
2021-12-21 23:07 ` 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

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.