GNU bug report logs - #71819
Incorrect substitution when undo replacing regexps

Previous Next

Package: emacs;

Reported by: Sab Pyrope <sab.pyrope <at> gmail.com>

Date: Fri, 28 Jun 2024 10:46:02 UTC

Severity: normal

To reply to this bug, email your comments to 71819 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#71819; Package emacs. (Fri, 28 Jun 2024 10:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sab Pyrope <sab.pyrope <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 28 Jun 2024 10:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sab Pyrope <sab.pyrope <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Incorrect substitution when undo replacing regexps
Date: Fri, 28 Jun 2024 08:57:03 +0800
[Message part 1 (text/plain, inline)]
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.
---

In GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
 cairo version 1.16.0) of 2024-05-20, modified by Debian built on sbuild
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.3/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.3/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --with-cairo --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/reproducible-path/emacs-29.3+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2
XPM GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: ru_RU.UTF-8
  value of $LC_NUMERIC: ru_RU.UTF-8
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: ru_RU.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  save-place-mode: t
  global-tab-line-mode: t
  tab-line-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  electric-pair-mode: t
  desktop-save-mode: t
  delete-selection-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug misearch multi-isearch mm-archive
message sendmail dired dired-loaddefs rfc822 mml mml-sec epa derived
gnus-util text-property-search mailabbrev gmm-utils mailheader mm-decode
mm-bodies mm-encode mail-utils mule-util gnutls network-stream url-cache
url-http url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr url-gw nsm puny epg rfc6068 epg-config comp comp-cstr
warnings cus-edit pp cus-start wid-edit cl-extra help-mode yank-media
markdown-mode thingatpt noutline outline icons time-date vc-git
diff-mode easy-mmode vc-dispatcher python rx project pcase treesit
comint ansi-osc ring ansi-color gruvbox-dark-hard-theme gruvbox
autothemer color lisp-mnt dash saveplace whitespace tab-line
display-line-numbers elec-pair desktop frameset delsel cus-load
finder-inf csv-mode-autoloads info markdown-mode-autoloads
po-mode-autoloads tree-sitter-autoloads tsc-autoloads package browse-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
cyril-util rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 422703 549886)
 (symbols 48 21740 133)
 (strings 32 123122 109316)
 (string-bytes 1 5309779)
 (vectors 16 36085)
 (vector-slots 8 683635 189466)
 (floats 8 249 448)
 (intervals 56 999 1339)
 (buffers 984 19))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71819; Package emacs. (Sat, 29 Jun 2024 11:53:01 GMT) Full text and rfc822 format available.

Message #8 received at 71819 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sab Pyrope <sab.pyrope <at> gmail.com>, Juri Linkov <juri <at> linkov.net>
Cc: 71819 <at> debbugs.gnu.org
Subject: Re: bug#71819: Incorrect substitution when undo replacing regexps
Date: Sat, 29 Jun 2024 14:52:34 +0300
> From: Sab Pyrope <sab.pyrope <at> gmail.com>
> Date: Fri, 28 Jun 2024 08:57:03 +0800
> 
> 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.
> ---

Thanks.

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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71819; Package emacs. (Sun, 30 Jun 2024 16:39:03 GMT) Full text and rfc822 format available.

Message #11 received at 71819 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71819 <at> debbugs.gnu.org, Sab Pyrope <sab.pyrope <at> gmail.com>,
 Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#71819: Incorrect substitution when undo replacing regexps
Date: Sun, 30 Jun 2024 19:25:11 +0300
>> 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).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71819; Package emacs. (Sat, 13 Jul 2024 10:00:02 GMT) Full text and rfc822 format available.

Message #14 received at 71819 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: tino.calancha <at> gmail.com, Juri Linkov <juri <at> linkov.net>
Cc: 71819 <at> debbugs.gnu.org, sab.pyrope <at> gmail.com
Subject: Re: bug#71819: Incorrect substitution when undo replacing regexps
Date: Sat, 13 Jul 2024 12:59:46 +0300
Ping!  Tino, can you please look into this issue?

> From: Juri Linkov <juri <at> linkov.net>
> Cc: Tino Calancha <tino.calancha <at> gmail.com>,  Sab Pyrope
>  <sab.pyrope <at> gmail.com>,  71819 <at> debbugs.gnu.org
> Date: Sun, 30 Jun 2024 19:25:11 +0300
> 
> >> 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).
> 




This bug report was last modified 201 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.