Subject: bug#25541: [PATCH 2/3] Fix fill-paragraph for comments in bat-mode

From: Vladimir Panteleev <[email-masked]>
Date: Thu, 26 Jan 2017 04:36:23 +0000

* lisp/progmodes/bat-mode.el: Set comment-start-skip.
* test/lisp/progmodes/bat-mode-tests.el: Add test.
---
 lisp/progmodes/bat-mode.el            |  1 +
 test/lisp/progmodes/bat-mode-tests.el | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el
index 77b97ac6ff..a945d37f1d 100644
--- a/lisp/progmodes/bat-mode.el
+++ b/lisp/progmodes/bat-mode.el
@@ -176,6 +176,7 @@ bat-mode
 Run script using `bat-run' and `bat-run-args'.\n
 \\{bat-mode-map}"
   (setq-local comment-start "rem ")
+  (setq-local comment-start-skip "rem[ \t]+")
   (setq-local syntax-propertize-function bat--syntax-propertize)
   (setq-local font-lock-defaults
        '(bat-font-lock-keywords nil t)) ; case-insensitive keywords
diff --git a/test/lisp/progmodes/bat-mode-tests.el b/test/lisp/progmodes/bat-mode-tests.el
index c78827db80..335fc16ffb 100644
--- a/test/lisp/progmodes/bat-mode-tests.el
+++ b/test/lisp/progmodes/bat-mode-tests.el
@@ -59,5 +59,19 @@ bat-test-fontify
     (bat-test-fontify "echo !a_b-c{d}e!")
     "<span class=\"builtin\">echo</span> !<span class=\"variable-name\">a_b-c{d}e</span>!")))
 
+(defun bat-test-fill-paragraph (str)
+  "Return the result of invoking `fill-paragraph' on STR in a `bat-mode' buffer."
+  (with-temp-buffer
+    (bat-mode)
+    (insert str)
+    (goto-char 1)
+    (font-lock-ensure)
+    (fill-paragraph)
+    (buffer-string)))
+
+(ert-deftest bat-test-fill-paragraph-comment ()
+  "Test `fill-paragraph' in a comment block."
+  (should (equal (bat-test-fill-paragraph "rem foo\nrem bar\n") "rem foo bar\n")))
+
 (provide 'bat-tests)
 ;;; bat-mode-tests.el ends here
-- 
2.11.0