[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27112: Setting comment-continue to " " causes uncomment-region-defau
From: |
npostavs |
Subject: |
bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop |
Date: |
Thu, 01 Jun 2017 23:18:22 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) |
tags 27112 patch
quit
Clément Pit--Claudel <clement.pitclaudel@live.com> writes:
>> Can you give a full recipe?
>
> Sure thing:
>
> emacs -Q --eval '(setq comment-continue " ")' --eval '(save-excursion
> (insert ";; AAA\n"))' --eval '(comment-line 1)'
Oh it triggers in lisp mode, I somehow got the idea that it needed a
mode with C like comments from initial report. How about this patch:
>From d7030832e1aecbb04affe52453fa32ea19ed7ded Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 1 Jun 2017 23:09:36 -0400
Subject: [PATCH v1] Fix infloop in uncomment-region-default (Bug#27112)
When `comment-continue' has only blank lines, `comment-padright'
produces a regexp that matches the empty string, so
`uncomment-region-default' will loop infinitely.
* lisp/newcomment.el (comment-padright): Check for non-padding
characters in STR.
---
lisp/newcomment.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 4b261c34c6..118549f421 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -815,7 +815,7 @@ (defun comment-padright (str &optional n)
If N is `re', a regexp is returned instead, that would match
the string for any N."
(setq n (or n 0))
- (when (and (stringp str) (not (string= "" str)))
+ (when (and (stringp str) (string-match "\\S-" str))
;; Separate the actual string from any leading/trailing padding
(string-match "\\`\\s-*\\(.*?\\)\\s-*\\'" str)
(let ((s (match-string 1 str)) ;actual string
--
2.11.1
- bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop,
npostavs <=