all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
@ 2017-05-28  6:27 Clément Pit--Claudel
  2017-05-30 22:23 ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Clément Pit--Claudel @ 2017-05-28  6:27 UTC (permalink / raw)
  To: 27112


[-- Attachment #1.1: Type: text/plain, Size: 647 bytes --]

Hi all,

Setting comment-continue to "  " breaks the logic of uncomment-region-default, causing it to get into an infinite loop (repeatedly matching an empty string at the same location).
uncomment-region-default is used by comment-line (C-x C-;).

Setting comment-continue to "  " could be a mistake, in which case this bug is a request to document the limitation :) Or it may be a valid value, in which case uncomment-region-default is broken.

The original context was comments like in a major mode that I'm writing, for which setting comment-continue to "  " seem(s/ed) reasonable.

/* AAA
   BBB
   CCC */

Cheers,
Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-05-28  6:27 bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop Clément Pit--Claudel
@ 2017-05-30 22:23 ` npostavs
  2017-05-30 23:02   ` Clément Pit--Claudel
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-05-30 22:23 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27112

Clément Pit--Claudel <clement.pitclaudel@live.com> writes:

> Setting comment-continue to " " breaks the logic of
> uncomment-region-default, causing it to get into an infinite loop
> (repeatedly matching an empty string at the same location).
> uncomment-region-default is used by comment-line (C-x C-;).

Can you give a full recipe?

> Setting comment-continue to " " could be a mistake, in which case this
> bug is a request to document the limitation :) Or it may be a valid
> value, in which case uncomment-region-default is broken.

I would consider uncomment-region-default broken regardless: even if
setting comment-continue to " " is a user error, the result should be to
throw an error, not infloop.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-05-30 22:23 ` npostavs
@ 2017-05-30 23:02   ` Clément Pit--Claudel
  2017-06-02  3:18     ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Clément Pit--Claudel @ 2017-05-30 23:02 UTC (permalink / raw)
  To: npostavs; +Cc: 27112


[-- Attachment #1.1: Type: text/plain, Size: 568 bytes --]

On 2017-05-30 18:23, npostavs@users.sourceforge.net wrote:
> Clément Pit--Claudel <clement.pitclaudel@live.com> writes:
> 
>> Setting comment-continue to " " breaks the logic of
>> uncomment-region-default, causing it to get into an infinite loop
>> (repeatedly matching an empty string at the same location).
>> uncomment-region-default is used by comment-line (C-x C-;).
> 
> Can you give a full recipe?

Sure thing:

emacs -Q --eval '(setq comment-continue "  ")' --eval '(save-excursion (insert ";; AAA\n"))' --eval '(comment-line 1)'

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-05-30 23:02   ` Clément Pit--Claudel
@ 2017-06-02  3:18     ` npostavs
  2017-06-10  2:15       ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-06-02  3:18 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27112

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1149 bytes --]

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-06-02  3:18     ` npostavs
@ 2017-06-10  2:15       ` npostavs
  2017-07-03 15:36         ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-06-10  2:15 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27112

npostavs@users.sourceforge.net writes:

> 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:

ping?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-06-10  2:15       ` npostavs
@ 2017-07-03 15:36         ` npostavs
  2017-07-03 15:41           ` Clément Pit--Claudel
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2017-07-03 15:36 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27112

npostavs@users.sourceforge.net writes:

> npostavs@users.sourceforge.net writes:
>
>> 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:
>
> ping?
ping?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-07-03 15:36         ` npostavs
@ 2017-07-03 15:41           ` Clément Pit--Claudel
  2017-07-05  0:08             ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Clément Pit--Claudel @ 2017-07-03 15:41 UTC (permalink / raw)
  To: npostavs; +Cc: 27112


[-- Attachment #1.1: Type: text/plain, Size: 384 bytes --]

On 2017-07-03 11:36, npostavs@users.sourceforge.net wrote:
> npostavs@users.sourceforge.net writes:
> 
>> npostavs@users.sourceforge.net writes:
>>
>>> 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:
>>
>> ping?
> ping?

Woops, sorry for the delay. Seems to work great here.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop
  2017-07-03 15:41           ` Clément Pit--Claudel
@ 2017-07-05  0:08             ` npostavs
  0 siblings, 0 replies; 8+ messages in thread
From: npostavs @ 2017-07-05  0:08 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27112

tags 27112 fixed
close 27112 26.1
quit

Clément Pit--Claudel <clement.pitclaudel@live.com> writes:

> Woops, sorry for the delay.

No worries.

> Seems to work great here.

Thanks for checking (I wasn't entirely sure if it would work correctly
for your use case), pushed to master.

[1: 2a9d7394e3]: 2017-07-04 20:04:42 -0400
  Fix infloop in uncomment-region-default (Bug#27112)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2a9d7394e36524c84fcbd61e4058b9fb89e3cc2b





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-07-05  0:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-28  6:27 bug#27112: Setting comment-continue to " " causes uncomment-region-default to infloop Clément Pit--Claudel
2017-05-30 22:23 ` npostavs
2017-05-30 23:02   ` Clément Pit--Claudel
2017-06-02  3:18     ` npostavs
2017-06-10  2:15       ` npostavs
2017-07-03 15:36         ` npostavs
2017-07-03 15:41           ` Clément Pit--Claudel
2017-07-05  0:08             ` npostavs

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.