more comment-reader spacing adjustments

svn: r14447
This commit is contained in:
Matthew Flatt 2009-04-07 19:07:08 +00:00
parent de3d090f1a
commit 9d563bf4f4
2 changed files with 15 additions and 9 deletions

View File

@ -32,6 +32,8 @@
(when (equal? #\; (peek-char port))
(read-char port)
(loop)))
(when (equal? #\space (peek-char port))
(read-char port))
`(code:comment
(unsyntax
(t
@ -53,18 +55,21 @@
(cond
[(null? l) (if (null? s)
null
(list (apply string-append (reverse s))))]
[(and (equal? " " (car l))
(pair? s)
(equal? " " (car s)))
(append (loop null s)
(cons ''nbsp
(loop (cdr l) null)))]
(preserve-space (apply string-append (reverse s))))]
[(string? (car l))
(loop (cdr l) (cons (car l) s))]
[else
(append (loop null s)
(cons
(car l)
(loop (cdr l) null)))]))))
(loop (cdr l) null)))])))
(define (preserve-space s)
(let ([m (regexp-match-positions #rx" +" s)])
(if m
(append (preserve-space (substring s 0 (caar m)))
(list `(hspace ,(- (cdar m) (caar m))))
(preserve-space (substring s (cdar m))))
(list s)))))

View File

@ -333,7 +333,8 @@
"does not have a single sub-form"
c)))
(advance c init-line!)
(out "; " comment-color)
(out ";" comment-color)
(out 'nbsp comment-color)
(let ([v (syntax->datum (cadr (syntax->list c)))])
(if (paragraph? v)
(map (lambda (v)