Ihor Radchenko <yanta...@gmail.com> writes:

>
> Thanks! Since Felipe has no objections, your patch should be good to apply.
>
> Could you kindly add the geiser version info as a comment inside code?
> Commit message is an unlikely place to be checked regularly and be
> noticed as geiser is updated in future.
>
> Comments are generally preferred over commit messages:
>
> https://orgmode.org/worg/org-contribute.html#commit-messages ->
> -> https://git.savannah.gnu.org/cgit/emacs.git/plain/CONTRIBUTE
>>> - Explaining the rationale for a design choice is best done in comments
>>>   in the source code.  However, sometimes it is useful to describe just
>>>   the rationale for a change; that can be done in the commit message
>>>   between the summary line and the file entries.
>
> Best,
> Ihor

Hello Ihor,

thank you for pointing that out, seems I botched my reading comprehension skill
check.

I have updated the patch and enclosed it, feel free to drop a line if you
notice anything else obviously missing.

Vale,

- Tim

From 3b4120d5b3fb41d4b0a5bbdee4cc7a3f4cd02642 Mon Sep 17 00:00:00 2001
From: Tim Van den Langenbergh <tmt_...@gmx.com>
Date: Sat, 23 Apr 2022 14:57:27 +0200
Subject: [PATCH] lisp/ob-scheme.el: Use synchronous eval.

* ob-scheme.el (org-babel-scheme-execute-with-geiser): If available,
use the synchronous `geiser-eval-region/wait' function to get the
evaluation result.

Works with geiser 0.18 (before introduction of async evaluation) and
geiser 0.22 (which introduces `geiser-eval-region/wait').

Modified from a patch proposal by Felipe Lema.

TINYCHANGE
---
 lisp/ob-scheme.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index 72d2e029e..b91c368a7 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -55,6 +55,8 @@
 (declare-function geiser-mode "ext:geiser-mode" ())
 (declare-function geiser-eval-region "ext:geiser-mode"
                   (start end &optional and-go raw nomsg))
+(declare-function geiser-eval-region/wait "ext:geiser-mode"
+                  (start end &optional timeout))
 (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))
@@ -176,7 +178,13 @@ is true; otherwise returns the last value."
 	  (setq geiser-impl--implementation nil)
 	  (let ((geiser-debug-jump-to-debug-p nil)
 		(geiser-debug-show-debug-p nil))
-	    (let ((ret (geiser-eval-region (point-min) (point-max))))
+            ;; `geiser-eval-region/wait' was introduced to await the
+            ;; result of async evaluation in geiser version 0.22.
+	    (let ((ret (funcall (if (fboundp 'geiser-eval-region/wait)
+                                    #'geiser-eval-region/wait
+                                  #'geiser-eval-region)
+                                (point-min)
+                                (point-max))))
 	      (setq result (if output
 			       (or (geiser-eval--retort-output ret)
 				   "Geiser Interpreter produced no output")
--
2.36.0

Reply via email to