GNU bug report logs -
#44581
28.0.50; undo comment-region error
Previous Next
Reported by: Mattias Engdegård <mattiase <at> acm.org>
Date: Wed, 11 Nov 2020 16:20:01 UTC
Severity: normal
Found in version 28.0.50
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44581 in the body.
You can then email your comments to 44581 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#44581
; Package
emacs
.
(Wed, 11 Nov 2020 16:20:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mattias Engdegård <mattiase <at> acm.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 11 Nov 2020 16:20:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In *scratch*, write
abc def
Mark 'abc', run 'comment-region', then 'undo'.
This results in the error
primitive-undo: Changes to be undone by function different from announced
with a backtrace if debug-on-error is set.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#44581
; Package
emacs
.
(Wed, 11 Nov 2020 16:34:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 44581 <at> debbugs.gnu.org (full text, mbox):
This is a regression from Emacs 26; the bug is present on emacs-27 and master.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#44581
; Package
emacs
.
(Wed, 11 Nov 2020 18:44:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 44581 <at> debbugs.gnu.org (full text, mbox):
This bug appears to be a consequence of eb0d10d567a. Alan, can you take a look?
The error does not appear if comment-combine-change-calls is set to nil.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#44581
; Package
emacs
.
(Sun, 15 Nov 2020 12:21:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 44581 <at> debbugs.gnu.org (full text, mbox):
Hello, Mattias.
On Wed, Nov 11, 2020 at 19:43:28 +0100, Mattias Engdegård wrote:
> This bug appears to be a consequence of eb0d10d567a. Alan, can you take a look?
> The error does not appear if comment-combine-change-calls is set to nil.
Yes. The region supplied to comment-region-default was (BEG END). But
changes were made outside of this region (namely, deletion of
whitespace), so the invocation of macro combine-change-calls was
invalid.
Changing the END argument to combine-change-calls to
beginning-of-next-line solves this problem.
Maybe I need the same change in uncomment-region-default too, but I'm
not sure.
Here is a provisional patch, based on the master branch (although the
fix should probably go into emacs-27). Could you test it, please.
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index e111ae8e22..3eb158dc2c 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1292,7 +1292,15 @@ comment-region-default-1
(defun comment-region-default (beg end &optional arg)
(if comment-combine-change-calls
- (combine-change-calls beg end (comment-region-default-1 beg end arg))
+ (combine-change-calls beg
+ ;; A new line might get inserted and whitespace deleted
+ ;; after END for line comments. Ensure the next argument is
+ ;; after any and all changes.
+ (save-excursion
+ (goto-char end)
+ (forward-line)
+ (point))
+ (comment-region-default-1 beg end arg))
(comment-region-default-1 beg end arg)))
;;;###autoload
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#44581
; Package
emacs
.
(Sun, 15 Nov 2020 12:31:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 44581 <at> debbugs.gnu.org (full text, mbox):
15 nov. 2020 kl. 13.20 skrev Alan Mackenzie <acm <at> muc.de>:
> Maybe I need the same change in uncomment-region-default too, but I'm
> not sure.
It seems more difficult to provoke uncomment-region to change text outside the region. Until we have a concrete example, better leave that code unchanged.
> Here is a provisional patch, based on the master branch (although the
> fix should probably go into emacs-27). Could you test it, please.
Seems to work nicely. Thank you!
Reply sent
to
Alan Mackenzie <acm <at> muc.de>
:
You have taken responsibility.
(Sun, 15 Nov 2020 13:33:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mattias Engdegård <mattiase <at> acm.org>
:
bug acknowledged by developer.
(Sun, 15 Nov 2020 13:33:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 44581-done <at> debbugs.gnu.org (full text, mbox):
Hello again, Mattias.
On Sun, Nov 15, 2020 at 13:30:28 +0100, Mattias Engdegård wrote:
> 15 nov. 2020 kl. 13.20 skrev Alan Mackenzie <acm <at> muc.de>:
> > Maybe I need the same change in uncomment-region-default too, but
> > I'm not sure.
> It seems more difficult to provoke uncomment-region to change text
> outside the region. Until we have a concrete example, better leave
> that code unchanged.
Yes, I agree.
> > Here is a provisional patch, based on the master branch (although the
> > fix should probably go into emacs-27). Could you test it, please.
> Seems to work nicely. Thank you!
Thanks! I've committed it to the emacs-27 branch, and I'm closing the
bug with this post.
--
Alan Mackenzie (Nuremberg, Germany).
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 14 Dec 2020 12:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 245 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.