From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Schenkel Subject: Re: [PATCH] guix: Fix handling of periods by fill-paragraph. Date: Sun, 27 Jul 2014 00:59:11 +0200 Message-ID: <87y4vfloao.fsf@gmail.com> References: <8738dndbkr.fsf@SIRIUS09.i-did-not-set--mail-host-address--so-tickle-me> <87wqazix9v.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBAvs-00044z-U4 for guix-devel@gnu.org; Sat, 26 Jul 2014 18:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBAvr-0003wB-KI for guix-devel@gnu.org; Sat, 26 Jul 2014 18:59:16 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:34321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBAvr-0003vy-A0 for guix-devel@gnu.org; Sat, 26 Jul 2014 18:59:15 -0400 Received: by mail-wg0-f46.google.com with SMTP id m15so5723853wgh.5 for ; Sat, 26 Jul 2014 15:59:14 -0700 (PDT) Received: from SIRIUS09 ([2a02:120b:c3f9:6f0:beae:c5ff:fe67:f79a]) by mx.google.com with ESMTPSA id au7sm36827881wjc.41.2014.07.26.15.59.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 26 Jul 2014 15:59:13 -0700 (PDT) In-Reply-To: <87wqazix9v.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 27 Jul 2014 00:13:32 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Cyrill Schenkel skribis: > >> From 2dc0cb0eaafbcfce062f4d0acbc7e5cad200bfbf Mon Sep 17 00:00:00 2001 >> From: Cyrill Schenkel >> Date: Sun, 27 Jul 2014 00:03:16 +0200 >> Subject: [PATCH] guix: Fix handling of periods by fill-paragraph. >> >> * guix/ui.scm (fill-paragraph): Two spaces after period and no spaces be= fore newline. > > Could you add a test in tests/ui.scm that demonstrates bug #17468? > > Also please add =E2=80=9CFixes .=E2=80=9D at t= he beginning of > the commit message. Done. Regards Cyrill --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-guix-Fix-handling-of-periods-by-fill-paragraph.patch >From f4240f7a360650383b1820dfe2004a0a3e3ffe50 Mon Sep 17 00:00:00 2001 From: Cyrill Schenkel Date: Sun, 27 Jul 2014 00:53:16 +0200 Subject: [PATCH] guix: Fix handling of periods by fill-paragraph. Fixes . * guix/ui.scm (fill-paragraph): Two spaces after period and no spaces before newline. * tests/ui.scm: New test case. --- guix/ui.scm | 25 +++++++++++++++---------- tests/ui.scm | 5 +++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 9112d55..f11c2e9 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))))))))) diff --git a/tests/ui.scm b/tests/ui.scm index 4bf7a77..7cc0264 100644 --- a/tests/ui.scm +++ b/tests/ui.scm @@ -67,6 +67,11 @@ interface, and powerful string processing.") 10) #\newline)) +(test-equal "fill-paragraph, two spaces after period" + "First line. Second line" + (fill-paragraph "First line. +Second line" 24)) + (test-equal "package-specification->name+version+output" '(("guile" #f "out") ("guile" "2.0.9" "out") -- 2.0.0 --=-=-=--