summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2026-05-27 18:32:40 +0300
committerJuri Linkov <juri@linkov.net>2026-05-27 18:32:40 +0300
commit2e70b88623ed4506c4334f8b9e73651f7d21ade7 (patch)
treef3325e10d5a71fecb9754ed3bada7faeef0e3f3f /test
parentea54c33950f5a360b08040a1412da36ffb14e704 (diff)
Fix fill-paragraph combining text with preceding comment
* lisp/textmodes/fill.el (fill-paragraph): Handle the case when a non-comment line follows a comment line with non-nil 'fill-paragraph-handle-comment' (bug#80449). Skip such a comment line before filling a non-comment line. * test/lisp/textmodes/fill-tests.el (fill-test-fill-paragraph-handle-comment): Add new test. * test/lisp/textmodes/fill-resources/fill-paragraph-handle-comment.erts: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/textmodes/fill-resources/fill-paragraph-handle-comment.erts37
-rw-r--r--test/lisp/textmodes/fill-tests.el4
2 files changed, 41 insertions, 0 deletions
diff --git a/test/lisp/textmodes/fill-resources/fill-paragraph-handle-comment.erts b/test/lisp/textmodes/fill-resources/fill-paragraph-handle-comment.erts
new file mode 100644
index 00000000000..c7c9e96ea50
--- /dev/null
+++ b/test/lisp/textmodes/fill-resources/fill-paragraph-handle-comment.erts
@@ -0,0 +1,37 @@
+Point-Char: |
+
+Name: fill-paragraph-handle-comment - non-comment line before comment line
+Code:
+ (lambda ()
+ (setq-local comment-start "# ")
+ (setq-local fill-paragraph-handle-comment t)
+ (setq-local fill-column 42)
+ (fill-paragraph))
+
+=-=
+
+this is not part of the comment this is not part of the comment|
+# this is a comment this is a comment this is a comment
+
+=-=
+
+this is not part of the comment this is
+not part of the comment
+# this is a comment this is a comment this is a comment
+
+=-=-=
+
+Name: fill-paragraph-handle-comment - non-comment line after comment line
+
+=-=
+
+# this is a comment this is a comment this is a comment
+this is not part of the comment this is not part of the comment|
+
+=-=
+
+# this is a comment this is a comment this is a comment
+this is not part of the comment this is
+not part of the comment
+
+=-=-=
diff --git a/test/lisp/textmodes/fill-tests.el b/test/lisp/textmodes/fill-tests.el
index 2bb9d3ea163..c37a879b4b2 100644
--- a/test/lisp/textmodes/fill-tests.el
+++ b/test/lisp/textmodes/fill-tests.el
@@ -163,6 +163,10 @@ eius. Foo")))
(skip-unless (functionp 'markdown-mode))
(ert-test-erts-file (ert-resource-file "fill-paragraph-semlf-markdown-mode.erts")))
+(ert-deftest fill-test-fill-paragraph-handle-comment ()
+ "Test the `fill-paragraph-handle-comment' variable."
+ (ert-test-erts-file (ert-resource-file "fill-paragraph-handle-comment.erts")))
+
(provide 'fill-tests)
;;; fill-tests.el ends here