[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-chez 7bc8f62 14/37: Capture stdout in ChezScheme's
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-chez 7bc8f62 14/37: Capture stdout in ChezScheme's eval:geiser |
Date: |
Sun, 1 Aug 2021 18:25:57 -0400 (EDT) |
branch: elpa/geiser-chez
commit 7bc8f62409b66bdb35b934c632d7fea12a53d636
Author: jitwit <jrn@bluefarm.ca>
Commit: jitwit <jrn@bluefarm.ca>
Capture stdout in ChezScheme's eval:geiser
---
scheme/chez/geiser/geiser.ss | 60 +++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 32 deletions(-)
diff --git a/scheme/chez/geiser/geiser.ss b/scheme/chez/geiser/geiser.ss
index 38bc68f..70b6b67 100644
--- a/scheme/chez/geiser/geiser.ss
+++ b/scheme/chez/geiser/geiser.ss
@@ -47,38 +47,34 @@
(define (geiser:eval module form . rest)
rest
- (let* ((body (lambda ()
- (if module
- (eval form (environment module))
- (eval form))))
- (gen-result (lambda (result-mid is-error?)
- (if is-error?
- `((result "")
- (output . "")
- (error . ,(list
- (cons 'key
- (with-output-to-string
- (lambda ()
- (display-condition
result-mid)))))))
- `((result ,(with-output-to-string
- (lambda ()
- (pretty-print result-mid))))
- (output . "")))))
- (result (call/cc
- (lambda (k)
- (with-exception-handler
- (lambda (e)
- (k (gen-result e #t)))
- (lambda ()
- (call-with-values
- (lambda ()
- (body))
- (lambda (x . y)
- (if (null? y)
- (k (gen-result x #f))
- (k (gen-result (cons x y) #f)))))))))))
- (write result)
- (newline)))
+ (let ((output-string (open-output-string)))
+ (write
+ (call/cc
+ (lambda (k)
+ (with-exception-handler
+ (lambda (e)
+ (k `((result "")
+ (output . ,(get-output-string output-string))
+ (error (key . ,(with-output-to-string
+ (lambda ()
+ (display-condition e))))))))
+ (lambda ()
+ (call-with-values
+ ;; evaluate form, allow for multiple return values,
+ ;; and capture output in output-string.
+ (lambda ()
+ (parameterize ((current-output-port output-string))
+ (if module
+ (eval form (environment module))
+ (eval form))))
+ (lambda result
+ `((result ,(with-output-to-string
+ (lambda ()
+ (pretty-print
+ (if (null? (cdr result)) (car result)
result)))))
+ (output . ,(get-output-string output-string))))))))))
+ (newline)
+ (close-output-port output-string)))
(define (geiser:module-completions prefix . rest)
(define (substring? s1 s2)
- [nongnu] elpa/geiser-chez 2a7a3f6 01/37: Add preliminary support for Chez Scheme, (continued)
- [nongnu] elpa/geiser-chez 2a7a3f6 01/37: Add preliminary support for Chez Scheme, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 1f1ee00 02/37: Clean-up elisp code, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 1bb0a87 06/37: Handle exceptions of ChezScheme and multi-value as well, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 993b630 07/37: Alway pretty-print for results, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez ab13b7f 03/37: Chez: add rudimentary autodoc support, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez e4c15a7 04/37: fix call the chez scheme executable., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 6a83bee 08/37: rewritten geiser:eval to fix the following bug:, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 2fb484b 05/37: Use (car (process-lines ...)) instead of (shell-command ...), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez a5a6176 11/37: fix compile and load for chez, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 2d682c0 13/37: fix for geiser-chez-parameters, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 7bc8f62 14/37: Capture stdout in ChezScheme's eval:geiser,
Philip Kaludercic <=
- [nongnu] elpa/geiser-chez 352515c 16/37: Begin the summary lines of all elisp libraries with three semicolons, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez a0f6fc3 15/37: Add rudimentary Chez support for macro expansion, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 146d4a7 18/37: Fix indentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 9d66c63 24/37: chez: pretty printing macroexpand results., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 502b3ac 20/37: Use cl-lib instead of cl, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 086dbba 23/37: make chez display output and error messages., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 94296d8 25/37: files moved from original import locations, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 111ecdd 26/37: scheme load path adjustments, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 055e43d 27/37: license and readme, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez e038c28 09/37: more reduction on geiser:eval, add test, Philip Kaludercic, 2021/08/01