I found `make-tentative-pretty-print-output-port` and 
`tentative-pretty-print-port-transfer` which looks like it might be the 
right way to go. I changed `write-now` as follows:

(define (write-now proc x port mode)
  (if (pretty-printing)
      (let* ([alt-port (make-tentative-pretty-print-output-port port
                                                                
(pretty-print-columns)
                                                                (λ () 
(void)))]
             [_ (proc x alt-port mode)])
        (tentative-pretty-print-port-transfer alt-port port))
      (let* ([alt-port (open-output-string)]
             [_ (proc x alt-port mode)]
             [str (get-output-string alt-port)])
        (write-string str port))))

And it looks like it mostly works, except that now it seems to ignore my 
`prop:custom-print-quotable 'never`, or else I am missing it somewhere... 
I'll investigate more.


But I don't understand how the `overflow-thunk` of 
`make-tentative-pretty-print-output-port` should be used. From the docs: 
"The overflow-thunk procedure is called if more than width items are 
printed to the port or if a newline is printed to the port via 
pretty-print-newline; it can escape from the recursive print through a 
continuation as a shortcut, but overflow-thunk can also return, in which 
case it is called every time afterward that additional output is written to 
the port."

Does that mean its return value is ignored? It seems like it. And when (if 
ever) should I call `tentative-pretty-print-port-cancel` instead of 
`tentative-pretty-print-port-transfer`?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8aefe2fa-49bf-4d05-84c1-612a54d99ff5%40googlegroups.com.

Reply via email to