summaryrefslogtreecommitdiff
path: root/scheme/geiser
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/geiser')
-rw-r--r--scheme/geiser/eval.scm12
1 files changed, 8 insertions, 4 deletions
diff --git a/scheme/geiser/eval.scm b/scheme/geiser/eval.scm
index 81b2647..450221a 100644
--- a/scheme/geiser/eval.scm
+++ b/scheme/geiser/eval.scm
@@ -31,16 +31,20 @@
(define (eval-in form module-name)
"Evals FORM in the module designated by MODULE-NAME.
If MODULE-NAME is #f or resolution fails, the current module is used instead.
-The result is a list of the form ((RESULT . <form-value>))
+The result is a list of the form ((RESULT . <form-value>) (OUTPUT . <string>))
if no evaluation error happens, or ((ERROR (KEY . <error-key>) <error-arg>...))
in case of errors. Each error arg is a cons (NAME . VALUE), where NAME includes
SUBR, MSG and REST."
(let ((module (or (and module-name (resolve-module module-name))
(current-module))))
(catch #t
- (lambda () (list (cons 'result (eval form module))))
- (lambda (key . args)
- (list (cons 'error (apply parse-error (cons key args))))))))
+ (lambda ()
+ (let* ((result #f)
+ (output (with-output-to-string
+ (lambda () (set! result (eval form module))))))
+ (list (cons 'result result) (cons 'output output))))
+ (lambda (key . args)
+ (list (cons 'error (apply parse-error (cons key args))))))))
(define (parse-error key . args)
(let* ((len (length args))