1

When I use the query-replace* (perform-replace) functions, I can type "," "to replace but not move point immediately."

During the replacement, the function highlights the match, but if I type ",", the replacement is performed, but the highlighting of the region containing the match is not removed.

For example, if I have the following strings in a buffer:

String to be replaced. Another string.

String to be replaced. Another string.

End

and I evaluate this code:

(query-replace "String to be replaced." "Replacement." nil (point-min) (point-max))

using the "," option, I get the behavior shown in the following .gif (uploading the .gif directly doesn't work):

https://imgur.com/a/BxVwVff

I find this annoying. Is this an intended behavior or is it a bug?

Note added. I am adding this clarification to better explain my request and to respond to NickD's comments.

The query-replace* (perform-replace) functions highlight the matches in the buffer for which it is possible to accept or reject the replacements. By typing , the act-and-show action in query-replace-map is called (as noted by NickD). act-and-show allows you to verify the result of the replacement before moving on to the next match. This way, you have the opportunity to undo or make further modifications by pausing the function if necessary.

What I find annoying is that act-and-show, once the replacement is made (and while waiting to move to the next match), continues to highlight the region of the buffer related to the match, potentially highlighting a portion of code that has nothing to do with the match or the replacement. I hope this clarification can explain my problem.

This is the highlight before act-and-show:

enter image description here

This is the highlight after act-and-show while query-replace is waiting for confirmation to move on to the next match:

enter image description here

As you can see, a part of the code that has nothing to do with the replacement is highlighted.

Note added. I submitted a bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71430

8
  • Is the annoying part that the highlight is not removed? If so, I'm guessing that since , is "bound" to act-and-show in query-replace-map, you might use a key that is "bound" to just act: there are several, the easiest one of which is <SPACE>, but y and Y should also do the same thing. But I may be misunderstanding. Commented May 21, 2024 at 0:34
  • @NickD Thanks, I know that I can use y etc. but sometimes I need to use act-and-show and I'd prefer the highlight to be removed because it confuses me. Commented May 21, 2024 at 10:39
  • Isn't the highlight the show part? Commented May 21, 2024 at 11:41
  • @NickD I think that the "replacement" should be the show part. I mean I need to see what the replacement is/does to choose whether to accept it or not. Commented May 21, 2024 at 15:17
  • I don't really understand what you want then. You say "I find this annoying" - what is this exactly? Ditto for "Is this an intended behavior..." - what is "this* exactly? Commented May 21, 2024 at 15:34

1 Answer 1

0

It seems to be a bug in Emacs 29. It was fixed in Emacs 30:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71430

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.