summaryrefslogtreecommitdiff
path: root/scheme/racket
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/racket')
-rw-r--r--scheme/racket/geiser/images.rkt15
-rw-r--r--scheme/racket/geiser/user.rkt8
2 files changed, 20 insertions, 3 deletions
diff --git a/scheme/racket/geiser/images.rkt b/scheme/racket/geiser/images.rkt
index 2cdcadb..b97546f 100644
--- a/scheme/racket/geiser/images.rkt
+++ b/scheme/racket/geiser/images.rkt
@@ -17,7 +17,9 @@
(provide image-cache
maybe-print-image
maybe-write-image
- make-port-print-handler)
+ make-port-print-handler
+ make-pretty-print-size-hook
+ make-pretty-print-print-hook)
(define image-cache
(let ([ensure-dir (lambda (dir)
@@ -51,3 +53,14 @@
(define (make-port-print-handler ph)
(lambda (value port . rest)
(apply ph (or (maybe-save-image value) value) port rest)))
+
+(define (make-pretty-print-size-hook [orig (pretty-print-size-hook)])
+ (lambda (value display? port)
+ (if (convertible? value)
+ (pretty-print-columns)
+ (orig value display? port))))
+
+(define (make-pretty-print-print-hook [orig (pretty-print-print-hook)])
+ (lambda (value display? port)
+ (let [(img (maybe-save-image value))]
+ (if img (print img port) (orig value display? port)))))
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt
index c566309..b936219 100644
--- a/scheme/racket/geiser/user.rkt
+++ b/scheme/racket/geiser/user.rkt
@@ -126,7 +126,9 @@
(define (install-print-handlers)
(for-each install-print-handler (list port-print-handler
port-write-handler
- port-display-handler)))
+ port-display-handler))
+ (pretty-print-print-hook (make-pretty-print-print-hook))
+ (pretty-print-size-hook (make-pretty-print-size-hook)))
(define (init-geiser-repl)
(compile-enforce-module-constants #f)
@@ -143,7 +145,9 @@
(current-error-port out)
(current-load/use-compiled (geiser-loader))
(current-prompt-read (geiser-prompt-read geiser-prompt))
- (current-print maybe-print-image)]
+ (current-print maybe-print-image)
+ (pretty-print-print-hook (make-pretty-print-print-hook))
+ (pretty-print-size-hook (make-pretty-print-size-hook))]
(install-print-handlers)
(preload-help)
(read-eval-print-loop)))