From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#71819: Incorrect substitution when undo replacing regexps Date: Sun, 30 Jun 2024 19:25:11 +0300 Organization: LINKOV.NET Message-ID: <86o77ipwyw.fsf@mail.linkov.net> References: <867ce8j799.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31143"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 71819@debbugs.gnu.org, Sab Pyrope , Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 30 18:39:29 2024 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 1sNxaL-0007vg-Cs for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jun 2024 18:39:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNxa9-0002Cz-Fp; Sun, 30 Jun 2024 12:39:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNxZv-00026H-Qz for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNxZv-0004l8-4L for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sNxZv-0003qz-1D for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jun 2024 16:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71819 X-GNU-PR-Package: emacs Original-Received: via spool by 71819-submit@debbugs.gnu.org id=B71819.171976548614707 (code B ref 71819); Sun, 30 Jun 2024 16:39:02 +0000 Original-Received: (at 71819) by debbugs.gnu.org; 30 Jun 2024 16:38:06 +0000 Original-Received: from localhost ([127.0.0.1]:58835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNxZ0-0003p8-Bl for submit@debbugs.gnu.org; Sun, 30 Jun 2024 12:38:06 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:42551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNxYy-0003oW-Fr for 71819@debbugs.gnu.org; Sun, 30 Jun 2024 12:38:04 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 57BEB1BF204; Sun, 30 Jun 2024 16:37:57 +0000 (UTC) In-Reply-To: <867ce8j799.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 29 Jun 2024 14:52:34 +0300") X-GND-Sasl: juri@linkov.net 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288209 Archived-At: >> I encountered a bug when replacing regular expressions. >> If you [u]ndo a previous change during the replacement process, subsequent changes to the \2 substitution >> will use the old undone result. >> >> Text: >> --- >> Aaaaa. Bbbb. >> Ccccc. Dddd. >> Eeeee. Ffff. >> Ggggg. Hhhh. >> --- >> Input regexp: \([.]\) \([A-Z]\) >> Output regexp: \1 \2 >> Bug: >> 1. Copy the text above to the buffer. >> 2. Enter the regular expressions to the interactive regexp replacement [C-M-%]. >> 3. Click [y] twice until the Ffff is highlighted. >> 4. Cancel the previous replacement via [u]. >> 5. Continue replacing [y] until the end. >> 6. Notice that all sentences except the first and second now begin with an incorrect letter D, which is not >> implied by the entered regexp, it should be F and H, as if it had been replaced, but without being undoed in >> the middle of the process. >> Output: >> --- >> Aaaaa. Bbbb. >> Ccccc. Dddd. >> Eeeee. Dfff. >> Ggggg. Dhhh. >> --- > > This is a regression between Emacs 26 and Emacs 27, perhaps as a side > effect of fixing bug#36328. Juri, could you please take a look? This is caused by the commit 30c4f35a6fc8 that introduced these lines: (when regexp-flag (setq next-replacement (nth 4 elt))) Maybe Tino knows how to fix this (Cc'ed).