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: Bob Floyd
Subject: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
Date: Mon, 25 Jan 2021 11:34:16 -0800

>This is strange because if there is no region selected, this means that
>it should replace everywhere in the whole buffer (but only when point is
>at the beginning of the buffer).

Agreed, but that is what it does. Perhaps a clue?

I put the message in below as you suggest, but the result is as though no
region is selected - it replaces everywhere in the whole buffer:

(interactive
   (let ((common
          (query-replace-read-args
           (concat "Query replace"
                   (if current-prefix-arg
                       (if (eq current-prefix-arg '-) " backward" " word")
                     "")
                   (if (use-region-p) " in region" ""))
           nil)))
     (list (nth 0 common) (nth 1 common) (nth 2 common)
           ;; These are done separately here
           ;; so that command-history will record these expressions
           ;; rather than the values they had this time.
           (if (use-region-p) (region-beginning))
           (if (use-region-p) (region-end))
           (nth 3 common)
           (if (use-region-p) (region-noncontiguous-p)))))
  (message "region: %S %S" start end)
  (perform-replace from-string to-string t nil delimited nil nil start end
backward region-noncontiguous-p))

And *Messages* only contains:

Mark saved where search started
Mark set [2 times]
Replaced 11 occurences

The region I selected contained only 3 occurences.

Have I put your message in the correct place?

-----Original Message-----
From: Juri Linkov [mailto:juri@linkov.net] 
Sent: Monday, January 25, 2021 10:54 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617@debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3

> It was doing the expected, correct, query replace, for the first, oh,
maybe
> six times, then got into the broken state and when I repeat the above
> sequence it behaves as if there was no region selected and no replacements
> are offered (Replaced 0 occurences).

This is strange because if there is no region selected, this means that
it should replace everywhere in the whole buffer (but only when point is
at the beginning of the buffer).

> It seems like something was not restored correctly. I cannot say I
precisely
> followed the above steps for the first times when it was working - I
wanted
> to vary the sequence a bit (sometimes entering from the keyboard,
sometimes
> selecting text from a lower line in the selection) to see if I could break
> it. I cannot be more specific about exactly which sequence broke it, only
> that now, when it's broken, it consistently does not work!

It could help you to debug when you insert the following line
in 'query-replace' immediately before the 'perform-replace' call:

  (message "region: %S %S" start end)

Then after query-replace you could check in the *Messages* buffer
and see the exact region boundaries used.  If there are 'nil' values,
this might mean there is a bug in save-mark-and-excursion.






reply via email to

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