summaryrefslogtreecommitdiff
path: root/test/lisp/simple-tests.el
diff options
context:
space:
mode:
authorSamuel Freilich <sfreilich@google.com>2017-08-23 13:40:45 -0400
committerNoam Postavsky <npostavs@gmail.com>2017-08-30 20:10:36 -0400
commitcda26e64621d71c6a797f694418d844a621998be (patch)
tree9ac729275eb1129bacb340ba849d84ffc4eb3a46 /test/lisp/simple-tests.el
parent160295867de98241a16f2ede93da7e825ed4406b (diff)
downloademacs-cda26e64621d71c6a797f694418d844a621998be.tar.gz
emacs-cda26e64621d71c6a797f694418d844a621998be.tar.bz2
emacs-cda26e64621d71c6a797f694418d844a621998be.zip
Do not split line before width of fill-prefix
When auto-filling a paragraph, don't split a line before the width of the fill-prefix, creating a subsequent line that is as long or longer (Bug#20774). * lisp/simple.el (do-auto-fill): Only consider break-points that are later in the line than the width of the fill-prefix. This is a more general solution than the previous logic, which only skipped over the exact fill-prefix. The fill-prefix doesn't necessarily match the prefix of the first line of a paragraph in adaptive-fill-mode.
Diffstat (limited to 'test/lisp/simple-tests.el')
-rw-r--r--test/lisp/simple-tests.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index ad7aee1db17..729001bdf3a 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -497,5 +497,19 @@ See Bug#21722."
(should (equal (line-number-at-pos 5) 3))
(should (equal (line-number-at-pos 7) 4)))))
+
+;;; Auto fill.
+
+(ert-deftest auto-fill-mode-no-break-before-length-of-fill-prefix ()
+ (with-temp-buffer
+ (setq-local fill-prefix " ")
+ (set-fill-column 5)
+ ;; Shouldn't break after 'foo' (3 characters) when the next
+ ;; line is indented >= to that, that woudln't result in shorter
+ ;; lines.
+ (insert "foo bar")
+ (do-auto-fill)
+ (should (string-equal (buffer-string) "foo bar"))))
+
(provide 'simple-test)
;;; simple-test.el ends here