Subject: bug#57293: 29.0.50; query-replace with Wdired skips symlink target

From: Juri Linkov <[email-masked]>
Date: Sun, 21 Aug 2022 19:37:13 +0300

>> > Maybe turning this new behavior on by default was too much (Juri)?
>>
>> Shouldn't we get the Emacs 28 behavior whether or not that option is
>> enabled though?  IOW, isn't this just a bug?
>
> The docstring says
>
>   Non-nil to search and replace in file names only.
>
> so it does look like the relevant control.  (But I wouldn't be surprised
> if I were missing something.)

The main question is what constitutes a file name?  The old definition
was that replaceable file names are everywhere where read-only is nil.
The new definition is that file names are everywhere where the
text property 'dired-filename' is non-nil.

So if "foo" in "bar -> foo" had the text property 'dired-filename',
query-replace would visit it as well.

But wouldn't such change break some other commands?

> I have a slight preference for getting the Emacs 28 behavior by default,
> but I'm okay either way.  If there had been a NEWS entry about the new
> option (hint hint :-)) I wouldn't have filed a bug.

A NEWS entry could be added too unless something like below will make it
obsolete.

> I agree with Michael's point about "\M-sf".  Right now, you get the
> filename-only behavior for isearch via a specific functions and
> keybindings, but for query-replace, the behavior is controlled by a user
> option.  More consistency between isearch and query-replace seems like
> it would be a good thing.

Please note that unlike the corresponding option dired-isearch-filenames
that is nil, it makes much more sense to enable wdired-search-replace-filenames
by default because renaming file names is the primary use of WDired.

> I did notice this NEWS entry:
>
>   *** Search and replace in Dired/Wdired supports more regexps.
>   For example, the regexp ".*" will match only characters that are part
>   of the file name.  Also "^.*$" can be used to match at the beginning
>   of the file name and at the end of the file name.
>
> Does that functionality require wdired-search-replace-filenames to be
> non-nil?

Indeed, when wdired-search-replace-filenames is nil, ".*" matches whole lines.