bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45617: <query-replace> loses the edit region. Works in 23.3, broke i


From: Juri Linkov
Subject: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
Date: Mon, 04 Jan 2021 19:37:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> 7. Nothing happens because the region in step (1) has been lost.
>>     It should ask to replace 4 ‘_xx’s in the region.
>
> I suspect this is due to changes in how selection works in Emacs.
> Those changes were made in Emacs 24; please see the section "Selection
> changes" in the file etc/NEWS.24, where you will also find
> instructions for getting back the old behavior.

I tried to fix this problem by this patch, and indeed it fixed it,
so the region boundaries are preserved even when changed during
the minibuffer reading the strings:

Attachment: query-replace-region.patch
Description: Text Data

But then I noticed this comment in 'query-replace':

           ;; These are done separately here
           ;; so that command-history will record these expressions
           ;; rather than the values they had this time.

And indeed this patch broke this feature, so region boundaries
are saved as numbers in command-history for repeat-complex-command
instead of such code:

  C-x M-: (query-replace "a" "z" nil (if (use-region-p) (region-beginning)) (if 
(use-region-p) (region-end)) nil nil)

But anyway this feature was broken by design and never worked:
with a compiled replace.el it saves region boundaries as numbers,
and only when 'query-replace' is manually evaluated with 'eval-defun',
only then region boundaries are saved as code to command-history.

So we could just delete 'fix_command' from callint.c,
and don't worry about such cases.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]