summaryrefslogtreecommitdiff
path: root/scheme/racket/geiser/user.rkt
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2014-12-29 02:46:12 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2014-12-29 02:46:12 +0100
commit0dbd605e631beea9b46f526deda2a7d05928c49f (patch)
tree7dea18a9634381e94c36bcd574911ec9b9299417 /scheme/racket/geiser/user.rkt
parenta1c1f48872801ed47ec056fffc585011a068907b (diff)
downloadgeiser-guile-0dbd605e631beea9b46f526deda2a7d05928c49f.tar.gz
geiser-guile-0dbd605e631beea9b46f526deda2a7d05928c49f.tar.bz2
Racket: show images with print, write and display
Up to now, we were only displaying images when printed as values by the REPL, but not when image values were explicitly print-ed, write-d or display-ed. This patch solves that problem by installing (semi) appropriate port-{print,write,display}-handler. This is still and incomplete solution in that those handlers (as well as the already installed current-print-handler) don't recurse over a value's structure and won't produce images embedded in other data structures, as discussed in issue #49.
Diffstat (limited to 'scheme/racket/geiser/user.rkt')
-rw-r--r--scheme/racket/geiser/user.rkt13
1 files changed, 12 insertions, 1 deletions
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt
index a35574b..c566309 100644
--- a/scheme/racket/geiser/user.rkt
+++ b/scheme/racket/geiser/user.rkt
@@ -119,12 +119,22 @@
(define (geiser-loader) (module-loader (current-load/use-compiled)))
+(define (install-print-handler handler)
+ (let ([p (current-output-port)])
+ (handler p (make-port-print-handler (handler p)))))
+
+(define (install-print-handlers)
+ (for-each install-print-handler (list port-print-handler
+ port-write-handler
+ port-display-handler)))
+
(define (init-geiser-repl)
(compile-enforce-module-constants #f)
(current-load/use-compiled (geiser-loader))
(preload-help)
(current-prompt-read (geiser-prompt-read geiser-prompt))
- (current-print maybe-print-image))
+ (current-print maybe-print-image)
+ (install-print-handlers))
(define (run-geiser-repl in out enforce-module-constants)
(parameterize [(compile-enforce-module-constants enforce-module-constants)
@@ -134,6 +144,7 @@
(current-load/use-compiled (geiser-loader))
(current-prompt-read (geiser-prompt-read geiser-prompt))
(current-print maybe-print-image)]
+ (install-print-handlers)
(preload-help)
(read-eval-print-loop)))