diff options
author | Cyrill Schenkel <cyrill.schenkel@gmail.com> | 2014-07-27 00:53:16 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-08-11 18:27:03 +0200 |
commit | 3a09e1d2e8ef976e5d5e35d47fcb92ae501a651e (patch) | |
tree | 38277f2a8ca11840d3e289fee0ec700ce221bd04 /guix/ui.scm | |
parent | ebc32b311088808d028804909c841154e5c8bc9f (diff) | |
download | gnu-guix-3a09e1d2e8ef976e5d5e35d47fcb92ae501a651e.tar gnu-guix-3a09e1d2e8ef976e5d5e35d47fcb92ae501a651e.tar.gz |
ui: Fix handling of periods by fill-paragraph.
Fixes <http://bugs.gnu.org/17468>.
* guix/ui.scm (fill-paragraph): Two spaces after period and no spaces before newline.
* tests/ui.scm: New test case.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 9112d55daf..f11c2e9c92 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -393,15 +393,17 @@ converted to a space; sequences of more than one line break are preserved." ((#\newline) `(,column ,(+ 1 newlines) ,chars)) (else - (let ((chars (case newlines - ((0) chars) - ((1) (cons #\space chars)) - (else - (append (make-list newlines #\newline) chars)))) - (column (case newlines - ((0) column) - ((1) (+ 1 column)) - (else 0)))) + (let* ((spaces (if (and (pair? chars) (eqv? (car chars) #\.)) 2 1)) + (chars (case newlines + ((0) chars) + ((1) + (append (make-list spaces #\space) chars)) + (else + (append (make-list newlines #\newline) chars)))) + (column (case newlines + ((0) column) + ((1) (+ spaces column)) + (else 0)))) (let ((chars (cons chr chars)) (column (+ 1 column))) (if (> column width) @@ -414,7 +416,10 @@ converted to a space; sequences of more than one line break are preserved." 0 ,(if (null? after) before - (append before (cons #\newline (cdr after))))) + (append before + (cons #\newline + (drop-while (cut eqv? #\space <>) + after))))) `(,column 0 ,chars))) ; unbreakable `(,column 0 ,chars))))))))) |