Subject: bug#14013: 24.3.50; dired-isearch-filenames-regexp is matching text outside filenames

From: Juri Linkov <[email-masked]>
Date: Tue, 08 Feb 2022 21:32:44 +0200

forcemerge 14013 29215
thanks

> Michael Heerdegen <[email-masked]> writes:
>
>> Right, thanks.  Now I'm beginning to understand how this code works.
>
> BTW, one (related) thing that I found problematic over the time: I like
> to use query-replace on file names in WDired.  There is no way to match
> the beginning of the file name - right?  That's sometimes a problem.  In
> this situation it is even better to use dired-isearch-filenames -> nil
> because then I can match the space character before the beginning of the
> file name.

Like was discussed in bug#53758, xref uses ".*" to replace in results
where search/replace should be performed only within boundaries of matches.
xref uses own search function:

         (replace-re-search-function
          (lambda (from &optional _bound noerror)
            (let (found pair)
              (while (and (not found) pairs)
                (setq pair (pop pairs)
                      current-beg (car pair)
                      current-end (cdr pair))
                (goto-char current-beg)
                (when (re-search-forward from current-end noerror)
                  (setq found t)))
              found)))

So maybe Dired/WDired could use a similar function.

But in any case it seems matching at the beginning of the file name with "^"
as also requested by Drew in bug#29215 (merged) is still impossible.