On Sat, Feb 15, 2020 at 10:33 AM John Cowan <xxxxxx@ccil.org> wrote:
Got it. Line breaking seems to be the hard part, based on the above-linked article and the descriptions in the TeXBook, because of the combinatorial explosion.

I once implemented a pretty printer for generated C++ code based on this paper: Strictly Pretty (Citeseer).  The algorithm is clearly described, and I'm sure that it would be easy to apply to Scheme.  (Alas, the references give no credit to earlier pretty printers in Lisp.  It's written as if Wadler invented pretty printing.)