emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/geiser-chibi c32bd70 20/38: Rewrite geiser:eval in order t


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-chibi c32bd70 20/38: Rewrite geiser:eval in order to make it compatible with org-babel.
Date: Sun, 1 Aug 2021 18:26:18 -0400 (EDT)

branch: elpa/geiser-chibi
commit c32bd701d705b1caf68c93a7f1b601caadaf8133
Author: Lockywolf <lockywolf@gmail.com>
Commit: Lockywolf <lockywolf@gmail.com>

    Rewrite geiser:eval in order to make it compatible with org-babel.
    
    * Add an additional guard construction to geiser:eval in order to
    catch unexpected I/O errors.
---
 elisp/geiser-chibi.el          |  5 +++--
 scheme/chibi/geiser/geiser.scm | 30 ++++++++++++++++--------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/elisp/geiser-chibi.el b/elisp/geiser-chibi.el
index 7108ee1..cee6c75 100644
--- a/elisp/geiser-chibi.el
+++ b/elisp/geiser-chibi.el
@@ -73,8 +73,7 @@ This function uses `geiser-chibi-init-file' if it exists."
        (format "(geiser:%s %s)" proc form)))))
 
 (defun geiser-chibi--get-module (&optional module)
-  (cond ((null module)
-         :f)
+  (cond ((null module)  :f)
         ((listp module) module)
         ((stringp module)
          (condition-case nil
@@ -92,7 +91,9 @@ This function uses `geiser-chibi-init-file' if it exists."
   (format "(import %s)" module))
 
 (defun geiser-chibi--exit-command () "(exit 0)")
+
 ;; 
+
 ;; ;;; REPL startup
 
 (defconst geiser-chibi-minimum-version "0.7.3")
diff --git a/scheme/chibi/geiser/geiser.scm b/scheme/chibi/geiser/geiser.scm
index 35a52b7..f12cbfc 100644
--- a/scheme/chibi/geiser/geiser.scm
+++ b/scheme/chibi/geiser/geiser.scm
@@ -30,27 +30,29 @@
 ;;> the result of evaluation \scheme{(write)}'d and the second
 ;;> field, \scheme{output}, contains everyting that the evaluation
 ;;> would print to the standard output.
+;;> In case of an exception, the message is formatted with
+;;> \scheme{(chibi show)} and written to both variables in addition
+;;> to whatever was already there.
 
 (define (geiser:eval module form . rest)
   rest
   (guard (err
          (else
-          ;; TODO:We need to save output when returning errors too. The
-          ;; output may very well be produced before an error occurs. But to
-          ;; implement it wisely, we probably need something like two guard
-          ;; expressions. For example, org-mode's ob-scheme.el needs it.:END
-
-          (write `((result ,(show #f err))))))
+          (write ; to standard output
+           "Geiser-chibi falure in scheme code.")
+          (show #t err)))
     (let* ((output (open-output-string))
           (result (parameterize ((current-output-port output))
-                    (if module
-                        (let ((mod (module-env (find-module module))))
-                          (eval form mod))
-                        (eval form))
-                    )
-                  ))
-      (write `((result ,(write-to-string result))
-               (output . ,(get-output-string output))))))
+                    (guard (err
+                            (else (show #t err)
+                                  (write-to-string (show #f err))))
+                      (if module
+                          (let ((mod (module-env (find-module module))))
+                            (eval form mod))
+                        (eval form))))))
+      (write ; to standard output (to comint)
+       `((result ,(write-to-string result))
+                 (output . ,(get-output-string output))))))
   (values))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]