summaryrefslogtreecommitdiff
path: root/scheme
diff options
context:
space:
mode:
authorLockywolf <lockywolf@gmail.com>2019-08-19 23:52:11 +0800
committerLockywolf <lockywolf@gmail.com>2019-08-20 11:49:23 +0800
commit17d1ba2164223242048c6eebd5ebba2b6cf4c83b (patch)
treee00ff16d941750a6d05c304b987f0d05d5be36d5 /scheme
parentab070092b1bc05b97825404c100f3da864e2d5ae (diff)
downloadgeiser-guile-17d1ba2164223242048c6eebd5ebba2b6cf4c83b.tar.gz
geiser-guile-17d1ba2164223242048c6eebd5ebba2b6cf4c83b.tar.bz2
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.
Diffstat (limited to 'scheme')
-rw-r--r--scheme/chibi/geiser/geiser.scm30
1 files changed, 16 insertions, 14 deletions
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))