]> git.eshelyaron.com Git - emacs.git/commitdiff
Partially revert a fill-region-as-paragraph regression
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 26 Jan 2022 15:17:49 +0000 (16:17 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 26 Jan 2022 15:20:05 +0000 (16:20 +0100)
* lisp/textmodes/fill.el (fill-region-as-paragraph): Revert
e186af261 (bug#53537), because it leads to regressions.  (But
leave tests in place.)

lisp/textmodes/fill.el
test/lisp/textmodes/fill-tests.el

index 92e50ec2908477f69336033440da7f70bab697d5..beb30c6e950647b1bedde19e4f024da25379659e 100644 (file)
@@ -714,8 +714,7 @@ space does not end a sentence, so don't break a line there."
     (or justify (setq justify (current-justification)))
 
     ;; Don't let Adaptive Fill mode alter the fill prefix permanently.
-    (let ((actual-fill-prefix fill-prefix)
-          (fill-prefix fill-prefix))
+    (let ((fill-prefix fill-prefix))
       ;; Figure out how this paragraph is indented, if desired.
       (when (and adaptive-fill-mode
                 (or (null fill-prefix) (string= fill-prefix "")))
@@ -755,18 +754,9 @@ space does not end a sentence, so don't break a line there."
 
        ;; This is the actual filling loop.
        (goto-char from)
-       (let ((first t)
-              linebeg)
-         (while (< (point) to)
-            ;; On the first line, there may be text in the fill prefix
-            ;; zone (when `fill-prefix' is specified externally, and
-            ;; not computed).  In that case, don't consider that area
-            ;; when trying to find a place to put a line break
-            ;; (bug#45720).
-            (if (not first)
-               (setq linebeg (point))
-              (setq first nil
-                    linebeg (+ (point) (length actual-fill-prefix))))
+       (let (linebeg)
+          (while (< (point) to)
+           (setq linebeg (point))
            (move-to-column (current-fill-column))
            (if (when (and (< (point) to) (< linebeg to))
                  ;; Find the position where we'll break the line.
index 39e5dd3d26cb38644be836c728f84e37b5e9a04a..8b9f144dfff0c3b818c92427491de3cec3e233b5 100644 (file)
@@ -45,6 +45,8 @@
     (should (string= (buffer-string) "Abc\nd efg\n(h ijk)."))))
 
 (ert-deftest fill-test-unbreakable-paragraph ()
+  ;; See bug#45720 and bug#53537.
+  :expected-result :failed
   (with-temp-buffer
     (let ((string "aaa =   baaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"))
       (insert string)
                (buffer-string)
                "aaa =   baaaaaaaa aaaaaaaaaa\n         aaaaaaaaaa\n")))))
 
+(ert-deftest test-fill-haskell ()
+  (should
+   (equal
+    (with-temp-buffer
+      (asm-mode)
+      (dolist (line '("  ;; a b c"
+                      "  ;; d e f"
+                      "  ;; x y z"
+                      "  ;; w"))
+        (insert line "\n"))
+      (goto-char (point-min))
+      (end-of-line)
+      (setf fill-column 10)
+      (fill-paragraph nil)
+      (buffer-string))
+    "  ;; a b c
+  ;; d e f
+  ;; x y z
+  ;; w
+")))
+
 (provide 'fill-tests)
 
 ;;; fill-tests.el ends here