make pretty-print-newline
work on any output port
The documentation says that it should work on any output port, although there's special treatment of ports that originate from `pretty-print` itself. Closes #1579.
This commit is contained in:
parent
572b96a6ef
commit
6c9dbea31f
|
@ -525,6 +525,13 @@
|
||||||
(pp v))
|
(pp v))
|
||||||
(test "(a 1)\n" get-output-string o))
|
(test "(a 1)\n" get-output-string o))
|
||||||
|
|
||||||
|
;; ----------------------------------------
|
||||||
|
;; check that `pretty-print-newline` works on any output port
|
||||||
|
|
||||||
|
(let ([o (open-output-bytes)])
|
||||||
|
(pretty-print-newline o 17)
|
||||||
|
(test "\n" get-output-string o))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(report-errs)
|
(report-errs)
|
||||||
|
|
|
@ -373,8 +373,14 @@
|
||||||
(define orig-write (port-write-handler (open-output-string)))
|
(define orig-write (port-write-handler (open-output-string)))
|
||||||
|
|
||||||
(define (pretty-print-newline pport width)
|
(define (pretty-print-newline pport width)
|
||||||
(let-values ([(l col p) (port-next-location pport)])
|
(cond
|
||||||
((printing-port-print-line pport) #t (or col 0) width)))
|
[(printing-port? pport)
|
||||||
|
(let-values ([(l col p) (port-next-location pport)])
|
||||||
|
((printing-port-print-line pport) #t (or col 0) width))]
|
||||||
|
[(output-port? pport)
|
||||||
|
(newline pport)]
|
||||||
|
[else
|
||||||
|
(raise-argument-error 'pretty-print-newline "output-port?" pport)]))
|
||||||
|
|
||||||
(define (tentative-pretty-print-port-transfer a-pport pport)
|
(define (tentative-pretty-print-port-transfer a-pport pport)
|
||||||
(let ([content ((get a-pport print-port-info-get-content))])
|
(let ([content ((get a-pport print-port-info-get-content))])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user