Subject: Re: bug#73635: dired-do-query-replace-regexp should check if files are selected first

From: Dan Jacobson <[email-masked]>
Date: Sat, 26 Oct 2024 05:53:14 +0800

>> > E.g., yes there were files selected, but we just did a first run, and
>> > are no longer looking at the dired buffer. We need to go back to the
>> > dired buffer first. Fine. But at least let the user know before they
>> > bother entering the from and to values.
>> 
>> It uses the filename under point if there are no marked files like all
>> dired commands.

EZ> Right, and so I think there's no bug here to fix, and I'm therefore
EZ> closing it.

There is no check that the user is staring at the dired buffer first
before asking for the two strings.

So the user thinks they can mark some files, have a look at one, and
then do dired-do-query-replace-regexp... and it asks for the two
strings, and then says they have not selected any files.

But they did select the files. But they need to be back in the dired
buffer before running dired-do-query-replace-regexp. So
dired-do-query-replace-regexp should tell them that, instead of asking
them for the two strings.

In fact what needs to be changed is:
dired-do-query-replace-regexp needs to first check if the current buffer
is a dired buffer.

And if it is not, it needs to say "Must be run in a dired buffer" and
quit.

(Even if there is only one dired buffer in buffer-list.)