* bug#44581: 28.0.50; undo comment-region error
@ 2020-11-11 16:19 Mattias Engdegård
2020-11-11 16:33 ` Mattias Engdegård
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2020-11-11 16:19 UTC (permalink / raw)
To: 44581
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#44581: 28.0.50; undo comment-region error
2020-11-11 16:19 bug#44581: 28.0.50; undo comment-region error Mattias Engdegård
@ 2020-11-11 16:33 ` Mattias Engdegård
2020-11-11 18:43 ` Mattias Engdegård
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2020-11-11 16:33 UTC (permalink / raw)
To: 44581
This is a regression from Emacs 26; the bug is present on emacs-27 and master.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#44581: 28.0.50; undo comment-region error
2020-11-11 16:33 ` Mattias Engdegård
@ 2020-11-11 18:43 ` Mattias Engdegård
2020-11-15 12:20 ` Alan Mackenzie
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2020-11-11 18:43 UTC (permalink / raw)
To: 44581; +Cc: Alan Mackenzie
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#44581: 28.0.50; undo comment-region error
2020-11-11 18:43 ` Mattias Engdegård
@ 2020-11-15 12:20 ` Alan Mackenzie
2020-11-15 12:30 ` Mattias Engdegård
0 siblings, 1 reply; 6+ messages in thread
From: Alan Mackenzie @ 2020-11-15 12:20 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: 44581
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).
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#44581: 28.0.50; undo comment-region error
2020-11-15 12:20 ` Alan Mackenzie
@ 2020-11-15 12:30 ` Mattias Engdegård
2020-11-15 13:31 ` Alan Mackenzie
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2020-11-15 12:30 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 44581
15 nov. 2020 kl. 13.20 skrev Alan Mackenzie <acm@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!
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#44581: 28.0.50; undo comment-region error
2020-11-15 12:30 ` Mattias Engdegård
@ 2020-11-15 13:31 ` Alan Mackenzie
0 siblings, 0 replies; 6+ messages in thread
From: Alan Mackenzie @ 2020-11-15 13:31 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: 44581-done
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@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).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-15 13:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-11 16:19 bug#44581: 28.0.50; undo comment-region error Mattias Engdegård
2020-11-11 16:33 ` Mattias Engdegård
2020-11-11 18:43 ` Mattias Engdegård
2020-11-15 12:20 ` Alan Mackenzie
2020-11-15 12:30 ` Mattias Engdegård
2020-11-15 13:31 ` Alan Mackenzie
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.