From: Vladimir Zolotykh
Subject: Using pretty printer
Date: 
Message-ID: <3CEBDB6B.17F8C91C@eurocom.od.ua>
Can CL pretty printer help me in the following situation ? In course
of a program long string are generated. For example

[One line originally]
delete from payment_detail where payment_id=781 or payment_id=7672 or \
payment_id=7080 or payment_id=6655 or payment_id=5930 or \
payment_id=5464 or payment_id=5638 or payment_id=4925 or \
payment_id=4667 or payment_id=3721 or payment_id=3321 or \
payment_id=4096 or payment_id=2656 or payment_id=1520 or \
payment_id=782 or payment_id=219;

They're produced with FORMAT. Could I use pretty printer to make them
more readable without rewriting code that outputs entirely ? Just
filling within particular margins would suffice. It is worth to
mention that strings could be quite different from the one shown
above. Anyway I'd like to do this job even if I should rewrite code
for that. If you have some recommendations it would be appreciated.

-- 
Vladimir Zolotykh

From: Pierre R. Mai
Subject: Re: Using pretty printer
Date: 
Message-ID: <87znyriz5v.fsf@orion.bln.pmsf.de>
Vladimir Zolotykh <······@eurocom.od.ua> writes:

> Can CL pretty printer help me in the following situation ? In course
> of a program long string are generated. For example
> 
> [One line originally]
> delete from payment_detail where payment_id=781 or payment_id=7672 or \
> payment_id=7080 or payment_id=6655 or payment_id=5930 or \
> payment_id=5464 or payment_id=5638 or payment_id=4925 or \
> payment_id=4667 or payment_id=3721 or payment_id=3321 or \
> payment_id=4096 or payment_id=2656 or payment_id=1520 or \
> payment_id=782 or payment_id=219;
> 
> They're produced with FORMAT. Could I use pretty printer to make them
> more readable without rewriting code that outputs entirely ? Just
> filling within particular margins would suffice. It is worth to
> mention that strings could be quite different from the one shown
> above. Anyway I'd like to do this job even if I should rewrite code
> for that. If you have some recommendations it would be appreciated.

* (format t "~A~{~< \\~%   ~1:; ~A~>~^ or~}~%" 
            "delete from payment_detail where"
            '("payment_id=781" "payment_id=7672" "payment_id=7080" 
              "payment_id=7080" "payment_id=7080" "payment_id=7080"))
delete from payment_detail where payment_id=781 or payment_id=7672 or \
    payment_id=7080 or payment_id=7080 or payment_id=7080 or payment_id=7080

See the Formatted Output section off the HyperSpec, especially
22.3.6.2 Tilde Less-Than-Sign: Justification, the part on ~:;.

The example code just uses the default line-length/margins of the
output stream, you can control this via arguments to ~:;, though.

I'm sure there's a way of getting the pretty-printer (either via
pprint, or via format) to do what you want, but the layout control
directives of FORMAT suffice, too.

Regs, Pierre.

PS: Yes, the given format control is quite hairy, and probably a
    good argument for a more verbose formatting language... ;)

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein
From: Vladimir Zolotykh
Subject: Re: Using pretty printer
Date: 
Message-ID: <3CECB88E.1039405F@eurocom.od.ua>
Thank you Pierre

Just what I've looked for. Powerful feature indeed

(format t 
	"delete from payment_detail where ~
~{~<~%  ~2,72:;payment_id=~D~>~^ or ~}~%" 
	'(781 2 3 4 5 6 5 0 10 10 2075 538))

This outputs

 delete from payment_detail where payment_id=781 or payment_id=2 or 
  payment_id=3 or payment_id=4 or payment_id=5 or payment_id=6 or 
  payment_id=5 or payment_id=0 or payment_id=10 or payment_id=10 or 
  payment_id=2075 or payment_id=538

-- 
Vladimir Zolotykh