Skip to content

Commit

Permalink
Don't pretty-print with non-default global print handler; closes #725
Browse files Browse the repository at this point in the history
For rationale, see racket-pretty-print's doc string.

Also improve the doc string to mention #%module-begin printing.
  • Loading branch information
greghendershott committed Oct 24, 2024
1 parent 1203449 commit 32ceb55
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion racket-custom.el
Original file line number Diff line number Diff line change
@@ -376,7 +376,17 @@ restart by using `racket-start-back-end'."
:safe #'booleanp)

(defcustom racket-pretty-print t
"Use pretty-print instead of print in REPL?"
"Set current-print to pretty-print instead of print, when possible?
The current-print parameter is used by read-eval-print-loop to
print values in the REPL, and by #%module-begin to print top
level values when the program is run.
Note: Even when this variable is true, avoid pretty-print when
global-port-print-handler is set to something other than
default-global-port-print-handler. In that case the language
might not use s-expressions (as racket/pretty assumes), and
anyway might print \"prettily\" by default."
:type 'boolean
:safe #'booleanp)

4 changes: 3 additions & 1 deletion racket/print.rkt
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@
(parameterize ([current-output-port out]
[print-syntax-width +inf.0])
(cond
[pretty?
[(and pretty?
(equal? (global-port-print-handler) ;#725.
default-global-port-print-handler))
(parameterize ([pretty-print-columns columns]
[pretty-print-size-hook (make-pp-size-hook pixels/char)]
[pretty-print-print-hook (make-pp-print-hook)])

0 comments on commit 32ceb55

Please sign in to comment.