aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Troestler2021-08-27 16:37:53 +0200
committerLars Ingebrigtsen2021-08-27 17:15:17 +0200
commit0d45ad99da4c7ba0a9928aab91ffa0ccdee5bf73 (patch)
tree7b745a9691c9858d23bb183ceaa6f3ac42306cef
parentf7da671493d11969651d76e9bc2676d935c9bb9c (diff)
downloademacs-0d45ad99da4c7ba0a9928aab91ffa0ccdee5bf73.tar.gz
emacs-0d45ad99da4c7ba0a9928aab91ffa0ccdee5bf73.zip
lisp/newcomment.el: Uncommenting with whitespace `comment-continue'
* lisp/newcomment.el (uncomment-region-default-1): Make all-whitespace `comment-continue' work (bug#50226). Copyright-paperwork-exempt: yes
-rw-r--r--lisp/newcomment.el3
-rw-r--r--test/lisp/newcomment-tests.el39
2 files changed, 41 insertions, 1 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 57a52effd14..b458f0356de 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -932,7 +932,8 @@ This function is the default value of `uncomment-region-function'."
932 (setq end (copy-marker end)) 932 (setq end (copy-marker end))
933 (let* ((numarg (prefix-numeric-value arg)) 933 (let* ((numarg (prefix-numeric-value arg))
934 (ccs comment-continue) 934 (ccs comment-continue)
935 (srei (comment-padright ccs 're)) 935 (srei (or (comment-padright ccs 're)
936 (and (stringp comment-continue) comment-continue)))
936 (csre (comment-padright comment-start 're)) 937 (csre (comment-padright comment-start 're))
937 (sre (and srei (concat "^\\s-*?\\(" srei "\\)"))) 938 (sre (and srei (concat "^\\s-*?\\(" srei "\\)")))
938 spt) 939 spt)
diff --git a/test/lisp/newcomment-tests.el b/test/lisp/newcomment-tests.el
new file mode 100644
index 00000000000..06c300a6731
--- /dev/null
+++ b/test/lisp/newcomment-tests.el
@@ -0,0 +1,39 @@
1;;; newcomment-tests.el -*- lexical-binding:t -*-
2
3;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25
26(ert-deftest test-uncomment-space-comment-continue ()
27 (let ((comment-style 'multi-line)
28 (comment-continue " ")
29 (text " a\n b"))
30 (should
31 (equal text
32 (with-temp-buffer
33 (c-mode)
34 (insert text)
35 (comment-region (point-min) (point-max))
36 (uncomment-region (point-min) (point-max))
37 (buffer-string))))))
38
39;;; newcomment-testsuite.el ends here