improve vertical positioning & paren shaping in syntax->string

This commit is contained in:
Matthew Butterick 2016-06-11 21:31:47 -07:00 committed by Vincent St-Amour
parent ecadde3a65
commit 9422d66601

View File

@ -14,7 +14,7 @@
(let ([c (syntax-column c)]
[l (syntax-line c)])
(when (and l (l . > . line))
(newline)
(for-each (λ (_) (newline)) (range (- l line)))
(set! line l)
(init-line!))
(when c
@ -55,10 +55,14 @@
((loop init-line!) i))]
[(pair? (syntax-e c))
(advance c init-line!)
(printf "(")
(define c-paren-shape (syntax-property c 'paren-shape))
(printf "~a" (or c-paren-shape #\())
(set! col (+ col 1))
(map (loop init-line!) (syntax->list c))
(printf ")")
(printf (case c-paren-shape
[(#\[) "]"]
[(#\{) "}"]
[else ")"]))
(set! col (+ col 1))]
[(vector? (syntax-e c))
(advance c init-line!)