<div dir="ltr">I forget the details, but maybe try to call the default pretty-print-print-line and add your own output there instead?<div><br></div><div>Robby</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, Jan 6, 2014 at 2:45 PM, Asumu Takikawa <span dir="ltr"><<a href="mailto:asumu@ccs.neu.edu" target="_blank">asumu@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
Does anyone know an easy way to add extra indentation to pretty printed<br>
output using racket/pretty?<br>
<br>
For example, suppose I want to add pretty printed output after part of<br>
an error message like:<br>
<br>
expected: (<pretty printed value><br>
<should be aligned like this>)<br>
<br>
I would want any linebreak-separated portions to align with the first<br>
line with "expected:".<br>
<br>
So far, I've tried using the `pretty-print-print-line` parameter to add<br>
some extra indentation, but it doesn't work like I expect. For example:<br>
<br>
#lang racket<br>
<br>
;; how much extra indentation to add<br>
(define indent 2)<br>
<br>
;; to parameterize `pretty-print-print-line`<br>
(define (print-line line-num out old-line-length cols)<br>
(cond [(and line-num<br>
(not (= line-num 0))<br>
(not (eq? cols 'infinity)))<br>
(newline out)<br>
;; these two lines differ from the default<br>
(display (make-string indent #\space) out)<br>
;; changing this to `indent` has weird behavior<br>
0]<br>
[else 0]))<br>
<br>
(parameterize ([pretty-print-print-line print-line])<br>
(display " ")<br>
(pretty-display<br>
'(λ (x y z)<br>
(aaaaaaaa bbbbbbbbbbbbbb cccccccccccccc ddddddddd eeeeeeee ffffffff ggggggg hhhhhhh)))<br>
(newline)<br>
(display " ")<br>
(pretty-display<br>
'(some-other-identifier (x y z)<br>
(aaaaaaaa bbbbbbbbbbbbbb cccccccccccccc ddddddddd eeeeeeee ffffffff ggggggg hhhhhhh)))<br>
(newline))<br>
<br>
The output I'd like to get is (indentation significant):<br>
<br>
(lambda (x y z)<br>
(aaaaaaaa<br>
bbbbbbbbbbbbbb<br>
cccccccccccccc<br>
ddddddddd<br>
eeeeeeee<br>
ffffffff<br>
ggggggg<br>
hhhhhhh))<br>
(some-other-identifier<br>
(x y z)<br>
(aaaaaaaa<br>
bbbbbbbbbbbbbb<br>
cccccccccccccc<br>
ddddddddd<br>
eeeeeeee<br>
ffffffff<br>
ggggggg<br>
hhhhhhh))<br>
<br>
but I get:<br>
<br>
(lambda (x y z)<br>
(aaaaaaaa<br>
bbbbbbbbbbbbbb<br>
cccccccccccccc<br>
ddddddddd<br>
eeeeeeee<br>
ffffffff<br>
ggggggg<br>
hhhhhhh))<br>
(some-other-identifier<br>
(x y z)<br>
(aaaaaaaa<br>
bbbbbbbbbbbbbb<br>
cccccccccccccc<br>
ddddddddd<br>
eeeeeeee<br>
ffffffff<br>
ggggggg<br>
hhhhhhh))<br>
<br>
Any idea what I'm doing wrong? There seems to be some extra indentation<br>
added to the output in the inner expression. Am I missing some obvious<br>
easy method to do this?<br>
<br>
Cheers,<br>
Asumu<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>