all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71819: Incorrect substitution when undo replacing regexps
@ 2024-06-28  0:57 Sab Pyrope
  2024-06-29 11:52 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Sab Pyrope @ 2024-06-28  0:57 UTC (permalink / raw)
  To: 71819

[-- Attachment #1: Type: text/plain, Size: 6217 bytes --]

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))

[-- Attachment #2: Type: text/html, Size: 8085 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#71819: Incorrect substitution when undo replacing regexps
  2024-06-28  0:57 bug#71819: Incorrect substitution when undo replacing regexps Sab Pyrope
@ 2024-06-29 11:52 ` Eli Zaretskii
  2024-06-30 16:25   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-06-29 11:52 UTC (permalink / raw)
  To: Sab Pyrope, Juri Linkov; +Cc: 71819

> From: Sab Pyrope <sab.pyrope@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?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#71819: Incorrect substitution when undo replacing regexps
  2024-06-29 11:52 ` Eli Zaretskii
@ 2024-06-30 16:25   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2024-06-30 16:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71819, Sab Pyrope, Tino Calancha

>> 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).





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-30 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28  0:57 bug#71819: Incorrect substitution when undo replacing regexps Sab Pyrope
2024-06-29 11:52 ` Eli Zaretskii
2024-06-30 16:25   ` Juri Linkov

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.