From: Alan Mackenzie <acm@muc.de>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 44581@debbugs.gnu.org
Subject: bug#44581: 28.0.50; undo comment-region error
Date: Sun, 15 Nov 2020 12:20:18 +0000 [thread overview]
Message-ID: <20201115122018.GC3913@ACM> (raw)
In-Reply-To: <7A64CD95-49C7-4C16-9FF8-5E2221CDCCB1@acm.org>
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).
next prev parent reply other threads:[~2020-11-15 12:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-11-15 12:30 ` Mattias Engdegård
2020-11-15 13:31 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201115122018.GC3913@ACM \
--to=acm@muc.de \
--cc=44581@debbugs.gnu.org \
--cc=mattiase@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.