summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elisp/geiser-eval.el1
-rw-r--r--scheme/geiser/eval.scm12
2 files changed, 9 insertions, 4 deletions
diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el
index 5369a1f..68ef1ca 100644
--- a/elisp/geiser-eval.el
+++ b/elisp/geiser-eval.el
@@ -108,6 +108,7 @@
(defsubst geiser-eval--retort-p (ret)
(and (listp ret) (or (assoc 'error ret) (assoc 'result ret))))
(defsubst geiser-eval--retort-result (ret) (cdr (assoc 'result ret)))
+(defsubst geiser-eval--retort-output (ret) (cdr (assoc 'output ret)))
(defsubst geiser-eval--retort-error (ret) (cdr (assoc 'error ret)))
(defsubst geiser-eval--error-key (err) (cdr (assoc 'key err)))
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))