unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42855: 28.0.50; Format flowed does not flow multiple lines into one
@ 2020-08-13 17:51 Ferdinand Pieper
  2020-08-14 14:15 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Ferdinand Pieper @ 2020-08-13 17:51 UTC (permalink / raw)
  To: 42855

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

Refilling of format=flowed text can not fill multiple lines into one
when it should (i.e. the summed line length is smaller than
fill-flowed-display-column.

Attached is a patch to fix this by collecting all flowed lines before
calling fill-region.

I hope I got the patch formatting correct. If not please let me know.

Best,



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.17.3) of 2020-06-25


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-flow-filling-for-flowing-multiple-flowed-lines.patch --]
[-- Type: text/x-patch, Size: 3623 bytes --]

From 6993fa8d1b6555de58a986a0a7f3c433d57029fa Mon Sep 17 00:00:00 2001
From: fpi <git@pie.tf>
Date: Thu, 13 Aug 2020 19:17:28 +0200
Subject: [PATCH] Fix flow filling for flowing multiple flowed lines

* lisp/mail/flow-fill.el (fill-flowed): Loop until all flowed lines
are collected.
* test/lisp/mail/flow-fill-tests.el (fill-flow-tests-fill-flowed-decode):
Also test for multiple flowed lines.
---
 lisp/mail/flow-fill.el            | 36 ++++++++++++++++++-------------
 test/lisp/mail/flow-fill-tests.el |  3 ++-
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lisp/mail/flow-fill.el b/lisp/mail/flow-fill.el
index af3b493a08..f4b5503119 100644
--- a/lisp/mail/flow-fill.el
+++ b/lisp/mail/flow-fill.el
@@ -131,31 +131,37 @@ fill-flowed
             (goto-char (match-end 0))
             (unless (looking-at " ")
               (insert " "))
-            (end-of-line)
-            (when (and (not (eobp))
-                       (save-excursion
-                         (forward-line 1)
-                         (looking-at (format "\\(%s ?\\)[^>]" prefix))))
-              ;; Delete the newline and the quote at the start of the
-              ;; next line.
-              (delete-region (point) (match-end 1))
-              (ignore-errors
+            (while (and (eq (char-before (line-end-position)) ?\s)
+                        (not (eobp))
+                        (save-excursion
+                          (forward-line 1)
+                          (looking-at (format "\\(%s ?\\)[^>]" prefix))))
+              (end-of-line)
+              (when (and (not (eobp))
+                         (save-excursion
+                           (forward-line 1)
+                           (looking-at (format "\\(%s ?\\)[^>]" prefix))))
+                ;; Delete the newline and the quote at the start of the
+                ;; next line.
+                (delete-region (point) (match-end 1))))
+                (ignore-errors
 		  (let ((fill-prefix (concat prefix " "))
 		        adaptive-fill-mode)
 		    (fill-region (line-beginning-position)
                                  (line-end-position)
-			         'left 'nosqueeze))))))
-         (t
+			         'left 'nosqueeze)))))
+          (t
           ;; Delete the newline.
           (when (eq (following-char) ?\s)
             (delete-char 1))
           ;; Hack: Don't do the flowing on the signature line.
           (when (and (not (looking-at "-- $"))
                      (eq (char-before (line-end-position)) ?\s))
-            (end-of-line)
-            (when delete-space
-              (delete-char -1))
-            (delete-char 1)
+            (while (eq (char-before (line-end-position)) ?\s)
+              (end-of-line)
+              (when delete-space
+                (delete-char -1))
+              (delete-char 1))
             (ignore-errors
 		(let ((fill-prefix ""))
 		  (fill-region (line-beginning-position)
diff --git a/test/lisp/mail/flow-fill-tests.el b/test/lisp/mail/flow-fill-tests.el
index 4d435aeda7..c2e4178b7d 100644
--- a/test/lisp/mail/flow-fill-tests.el
+++ b/test/lisp/mail/flow-fill-tests.el
@@ -35,7 +35,8 @@ fill-flow-tests-fill-flowed-decode
           ">>> unmuzzled ratsbane!\n"
           ">>>> Henceforth, the coding style is to be strictly \n"
           ">>>> enforced, including the use of only upper case.\n"
-          ">>>>> I've noticed a lack of adherence to the coding \n"
+          ">>>>> I've noticed a lack of adherence to \n"
+          ">>>>> the coding \n"
           ">>>>> styles, of late.\n"
           ">>>>>> Any complaints?\n"))
         (output
-- 
2.27.0


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

* bug#42855: 28.0.50; Format flowed does not flow multiple lines into one
  2020-08-13 17:51 bug#42855: 28.0.50; Format flowed does not flow multiple lines into one Ferdinand Pieper
@ 2020-08-14 14:15 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-14 14:15 UTC (permalink / raw)
  To: Ferdinand Pieper; +Cc: 42855

Ferdinand Pieper <fer@pie.tf> writes:

> Refilling of format=flowed text can not fill multiple lines into one
> when it should (i.e. the summed line length is smaller than
> fill-flowed-display-column.
>
> Attached is a patch to fix this by collecting all flowed lines before
> calling fill-region.
>
> I hope I got the patch formatting correct. If not please let me know.

Yup; looks good.

I've now applied this to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2020-08-14 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 17:51 bug#42855: 28.0.50; Format flowed does not flow multiple lines into one Ferdinand Pieper
2020-08-14 14:15 ` Lars Ingebrigtsen

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

	https://git.savannah.gnu.org/cgit/emacs.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).