unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] guix: Fix handling of periods by fill-paragraph.
@ 2014-07-26 22:01 Cyrill Schenkel
  2014-07-26 22:06 ` Cyrill Schenkel
  0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Schenkel @ 2014-07-26 22:01 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

Hi.

This is a fix for the bug #17468.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-guix-Fix-handling-of-periods-by-fill-paragraph.patch --]
[-- Type: text/x-diff, Size: 1725 bytes --]

From 9fc7a445ad0249c0f4824b5f5338aa9aa6c16237 Mon Sep 17 00:00:00 2001
From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
Date: Sun, 27 Jul 2014 00:00:09 +0200
Subject: [PATCH] guix: Fix handling of periods by fill-paragraph.

* guix/ui.scm (fill-paragraph): Two spaces after period and no spaces before newline.
---
 guix/ui.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 9112d55..d8b0109 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -395,7 +395,9 @@ converted to a space; sequences of more than one line break are preserved."
          (else
           (let ((chars  (case newlines
                           ((0) chars)
-                          ((1) (cons #\space chars))
+                          ((1)
+                           (append (make-list (if (eqv? (car chars) #\.) 2 1)
+                                    #\space) chars))
                           (else
                            (append (make-list newlines #\newline) chars))))
                 (column (case newlines
@@ -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)))))))))
 
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] guix: Fix handling of periods by fill-paragraph.
  2014-07-26 22:01 [PATCH] guix: Fix handling of periods by fill-paragraph Cyrill Schenkel
@ 2014-07-26 22:06 ` Cyrill Schenkel
  2014-07-26 22:13   ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Schenkel @ 2014-07-26 22:06 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 98 bytes --]

Hi.

There was invalidly indented code in my previously sent patch.
So here's an updated version.

[-- Attachment #2: 0001-guix-Fix-handling-of-periods-by-fill-paragraph.patch --]
[-- Type: text/x-patch, Size: 1735 bytes --]

From 2dc0cb0eaafbcfce062f4d0acbc7e5cad200bfbf Mon Sep 17 00:00:00 2001
From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
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 before newline.
---
 guix/ui.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 9112d55..74d227d 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -395,7 +395,9 @@ converted to a space; sequences of more than one line break are preserved."
          (else
           (let ((chars  (case newlines
                           ((0) chars)
-                          ((1) (cons #\space chars))
+                          ((1)
+                           (append (make-list (if (eqv? (car chars) #\.) 2 1)
+                                              #\space) chars))
                           (else
                            (append (make-list newlines #\newline) chars))))
                 (column (case newlines
@@ -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)))))))))
 
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] guix: Fix handling of periods by fill-paragraph.
  2014-07-26 22:06 ` Cyrill Schenkel
@ 2014-07-26 22:13   ` Ludovic Courtès
  2014-07-26 22:59     ` Cyrill Schenkel
  0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2014-07-26 22:13 UTC (permalink / raw)
  To: Cyrill Schenkel; +Cc: Guix-devel

Cyrill Schenkel <cyrill.schenkel@gmail.com> skribis:

> From 2dc0cb0eaafbcfce062f4d0acbc7e5cad200bfbf Mon Sep 17 00:00:00 2001
> From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
> 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 before newline.

Could you add a test in tests/ui.scm that demonstrates bug #17468?

Also please add “Fixes <http://bugs.gnu.org/17468>.” at the beginning of
the commit message.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] guix: Fix handling of periods by fill-paragraph.
  2014-07-26 22:13   ` Ludovic Courtès
@ 2014-07-26 22:59     ` Cyrill Schenkel
  2014-08-11 16:37       ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Schenkel @ 2014-07-26 22:59 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:

> Cyrill Schenkel <cyrill.schenkel@gmail.com> skribis:
>
>> From 2dc0cb0eaafbcfce062f4d0acbc7e5cad200bfbf Mon Sep 17 00:00:00 2001
>> From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
>> 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 before newline.
>
> Could you add a test in tests/ui.scm that demonstrates bug #17468?
>
> Also please add “Fixes <http://bugs.gnu.org/17468>.” at the beginning of
> the commit message.

Done.

Regards

Cyrill


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-guix-Fix-handling-of-periods-by-fill-paragraph.patch --]
[-- Type: text/x-diff, Size: 3007 bytes --]

From f4240f7a360650383b1820dfe2004a0a3e3ffe50 Mon Sep 17 00:00:00 2001
From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
Date: Sun, 27 Jul 2014 00:53:16 +0200
Subject: [PATCH] guix: 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.
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] guix: Fix handling of periods by fill-paragraph.
  2014-07-26 22:59     ` Cyrill Schenkel
@ 2014-08-11 16:37       ` Ludovic Courtès
  0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2014-08-11 16:37 UTC (permalink / raw)
  To: Cyrill Schenkel; +Cc: Guix-devel

Cyrill Schenkel <cyrill.schenkel@gmail.com> skribis:

> From f4240f7a360650383b1820dfe2004a0a3e3ffe50 Mon Sep 17 00:00:00 2001
> From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
> Date: Sun, 27 Jul 2014 00:53:16 +0200
> Subject: [PATCH] guix: 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.

Applied, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-11 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-26 22:01 [PATCH] guix: Fix handling of periods by fill-paragraph Cyrill Schenkel
2014-07-26 22:06 ` Cyrill Schenkel
2014-07-26 22:13   ` Ludovic Courtès
2014-07-26 22:59     ` Cyrill Schenkel
2014-08-11 16:37       ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).