emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "Rudolf Adamkovič" <salutis@me.com>, emacs-orgmode@gnu.org
Subject: Re: Babel (scheme): Evaluation errors are not shown
Date: Sat, 7 Jan 2023 15:26:04 +0100	[thread overview]
Message-ID: <CAEYrNrSXqoohzDyjtTwB22TdAuot2+4YgiD8SD3LB7_vDuteEw@mail.gmail.com> (raw)
In-Reply-To: <87k024kmvf.fsf@localhost>

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

Am Sa., 7. Jan. 2023 um 08:44 Uhr schrieb Ihor Radchenko <yantar92@posteo.net>:
>
> Marc Nieper-Wißkirchen <marc@nieper-wisskirchen.de> writes:
>
> >> Thanks!
> >> Note that your patch does not apply onto main.
> >
> > Rebased against the latest main.  Please see the appended patch.
>
> Hmm.
> Not sure what is going on here, but I am getting
>
> 128 git … am --3way -- /tmp/0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
> Applying: lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
> Using index info to reconstruct a base tree...
> error: patch failed: lisp/ob-scheme.el:194
> error: lisp/ob-scheme.el: patch does not apply
> error: Did you hand edit your patch?
> It does not apply to blobs recorded in its index.
> Patch failed at 0001 lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".

Okay, apparently, `git format-patch -w' to ignore whitespace changes
does not work (at least not as simple as I thought).

A new patch file is attached; `git am' against the upstream head works here.

Thanks,

Marc

>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>

[-- Attachment #2: 0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch --]
[-- Type: application/octet-stream, Size: 4189 bytes --]

From ad7c32487954b055f156bafb8df591e2af2106fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc=20Nieper-Wi=C3=9Fkirchen?= <marc@nieper-wisskirchen.de>
Date: Sat, 31 Dec 2022 15:41:59 +0100
Subject: [PATCH] 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'.
---
 lisp/ob-eval.el   | 11 ++++++++---
 lisp/ob-scheme.el | 20 +++++++++++++++-----
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
index 6f6edb949..b9d1f7f23 100644
--- a/lisp/ob-eval.el
+++ b/lisp/ob-eval.el
@@ -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.
diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index ef41a2ec4..a8cf7de45 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -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))
-- 
2.34.1


  reply	other threads:[~2023-01-07 14:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 12:03 Babel (scheme): Evaluation errors are not shown Marc Nieper-Wißkirchen
2022-12-18 12:41 ` Ihor Radchenko
2022-12-20  0:39   ` Rudolf Adamkovič
2022-12-20 20:00     ` Marc Nieper-Wißkirchen
2022-12-31  9:50       ` Ihor Radchenko
2022-12-31 10:09         ` Marc Nieper-Wißkirchen
2022-12-31 10:19           ` Marc Nieper-Wißkirchen
2022-12-31 10:50             ` Marc Nieper-Wißkirchen
2022-12-31 12:07               ` Ihor Radchenko
2022-12-31 13:11                 ` Marc Nieper-Wißkirchen
2022-12-31 13:24                   ` Ihor Radchenko
2022-12-31 14:46                     ` Marc Nieper-Wißkirchen
2023-01-01 13:53                       ` Ihor Radchenko
2023-01-01 15:21                         ` Marc Nieper-Wißkirchen
2023-01-02  9:38                           ` Ihor Radchenko
2023-01-02  9:52                             ` Marc Nieper-Wißkirchen
2023-01-03  9:07                               ` Ihor Radchenko
2023-01-07 14:26                                 ` Marc Nieper-Wißkirchen [this message]
2023-01-25 13:12                                   ` Ihor Radchenko
2023-01-05  8:55                               ` Marc Nieper-Wißkirchen
2023-01-06 16:17                                 ` Ihor Radchenko
2023-01-06 16:20                                   ` Ihor Radchenko
2023-01-06 16:32                                     ` tomas
2023-01-06 20:47                                       ` Marc Nieper-Wißkirchen
2023-01-07 13:28                                   ` Bastien Guerry
2022-12-21 13:25     ` Ihor Radchenko
2022-12-29 15:34       ` Bastien Guerry
2023-01-03 23:28         ` Rudolf Adamkovič
2023-01-03 23:35           ` Bastien
2023-01-06 20:45             ` Rudolf Adamkovič

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=CAEYrNrSXqoohzDyjtTwB22TdAuot2+4YgiD8SD3LB7_vDuteEw@mail.gmail.com \
    --to=marc.nieper+gnu@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=salutis@me.com \
    --cc=yantar92@posteo.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).