From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#44581: 28.0.50; undo comment-region error Date: Sun, 15 Nov 2020 12:20:18 +0000 Message-ID: <20201115122018.GC3913@ACM> References: <5FB7F45B-CC9B-491B-ABFA-5AAB455D1196@acm.org> <7A64CD95-49C7-4C16-9FF8-5E2221CDCCB1@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4661"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44581@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 15 13:21:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1keH1v-00017C-9I for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Nov 2020 13:21:15 +0100 Original-Received: from localhost ([::1]:59036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keH1u-00060v-C9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Nov 2020 07:21:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keH1i-00060k-Rf for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 07:21:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1keH1i-0006dh-IV for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 07:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1keH1i-0007OX-Ds for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 07:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Nov 2020 12:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44581 X-GNU-PR-Package: emacs Original-Received: via spool by 44581-submit@debbugs.gnu.org id=B44581.160544282828361 (code B ref 44581); Sun, 15 Nov 2020 12:21:02 +0000 Original-Received: (at 44581) by debbugs.gnu.org; 15 Nov 2020 12:20:28 +0000 Original-Received: from localhost ([127.0.0.1]:52688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keH1A-0007NM-5n for submit@debbugs.gnu.org; Sun, 15 Nov 2020 07:20:28 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:61016 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1keH18-0007N9-7C for 44581@debbugs.gnu.org; Sun, 15 Nov 2020 07:20:27 -0500 Original-Received: (qmail 43842 invoked by uid 3782); 15 Nov 2020 12:20:19 -0000 Original-Received: from acm.muc.de (p4fe15510.dip0.t-ipconnect.de [79.225.85.16]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Sun, 15 Nov 2020 13:20:18 +0100 Original-Received: (qmail 23782 invoked by uid 1000); 15 Nov 2020 12:20:18 -0000 Content-Disposition: inline In-Reply-To: <7A64CD95-49C7-4C16-9FF8-5E2221CDCCB1@acm.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193354 Archived-At: 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).