You can change `print` for a specific port with `port-print-handler`.
There's also the `global-port-print-handler` parameter, but setting
that changes `print` only for ports that uses the default printer.
The blue-versus-purple distinction in DrRacket is built into the output
port that DrRacket supplies a `current-output-port`. That port has a
print handler that works with the destination editor to show `print`
output in blue, while other output to the port is shown in purple. I
don't think it's possible to change the way `print` works and still
have it in blue, but others (especially Robby) might know otherwise,
At Mon, 6 Mar 2017 20:48:17 -0800 (PST), Vasily Rybakov wrote:
> I want to change how Racket prints some values both in REPL and when using
> (print), (println), e.t.c.
> Suppose that I want change like this (gives as simple example):
> (define (print~ datum [out (current-output-port)] [quote-depth 0])
> (if (number? datum)
> (print `',datum out 1)
> (print datum out quote-depth)))
> So Racket will print all numbers with preceeding quote.
> This definition is in separate file and is exported like this:
> (provide (rename-out [print~ print]))
> So in other files it is seen as (print) function.
> 1. Although it redefines (print), it does not affect (println) and other
> Is there a way to re-define print and make Racket use it for other printing
> functions (because I suspect that their definitions are based on (print))?
> Or I should redefine all printing functions?
> 2. When I try to make REPL use this function for printing I hook it like this:
> (current-print (lambda (val)
> (if (void? val)
> (print val)
> Here (print) is modifyed print from example imported with the name of
> It seems to work, but it prints output to REPL in purple color, while by
> default it prints in the same colours as inputed values, so it easier to
> differentiate between REPL output and output generated by explicit use of
> Did I hook my custom print function wrong? Did I used wrong type of function?
> Is there a way to fix this?
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.