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