emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 85b8609: Tweak how auto-fill fills after a period


From: Lars Ingebrigtsen
Subject: master 85b8609: Tweak how auto-fill fills after a period
Date: Mon, 11 Oct 2021 04:18:08 -0400 (EDT)

branch: master
commit 85b8609f9572eb4d9d6d6f856097090513051ab5
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Tweak how auto-fill fills after a period
    
    * lisp/textmodes/fill.el (fill-nobreak-p): Don't break immediately
    after a space after a period (bug#17321).
---
 lisp/textmodes/fill.el            |  8 ++------
 test/lisp/textmodes/fill-tests.el | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index decce88..73d76a8 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -396,12 +396,8 @@ and `fill-nobreak-invisible'."
          (save-excursion
            (skip-chars-backward " ")
            (and (eq (preceding-char) ?.)
-                (looking-at " \\([^ ]\\|$\\)"))))
-     ;; Another approach to the same problem.
-     (save-excursion
-       (skip-chars-backward " ")
-       (and (eq (preceding-char) ?.)
-           (not (progn (forward-char -1) (looking-at (sentence-end))))))
+                 ;; There's something more after the space.
+                (looking-at " [^ \n]"))))
      ;; Don't split a line if the rest would look like a new paragraph.
      (unless use-hard-newlines
        (save-excursion
diff --git a/test/lisp/textmodes/fill-tests.el 
b/test/lisp/textmodes/fill-tests.el
index fcc2c75..2a1195b 100644
--- a/test/lisp/textmodes/fill-tests.el
+++ b/test/lisp/textmodes/fill-tests.el
@@ -76,6 +76,28 @@
                (buffer-string)
                "aaa =   baaaaaaaa aaaaaaaaaa\n         aaaaaaaaaa\n")))))
 
+(ert-deftest test-fill-end-period ()
+  (should
+   (equal
+    (with-temp-buffer
+      (text-mode)
+      (auto-fill-mode)
+      (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed 
do eius.")
+      (self-insert-command 1 ?\s)
+      (buffer-string))
+    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eius. "))
+  (should
+   (equal
+    (with-temp-buffer
+      (text-mode)
+      (auto-fill-mode)
+      (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed 
do eius.Foo")
+      (forward-char -3)
+      (self-insert-command 1 ?\s)
+      (buffer-string))
+    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+eius. Foo")))
+
 (provide 'fill-tests)
 
 ;;; fill-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]