unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* wdired replace-regexp (continue bug 14013?)
@ 2024-09-03 10:07 Madhu
  2024-09-03 12:24 ` Michael Heerdegen via Emacs development discussions.
  0 siblings, 1 reply; 5+ messages in thread
From: Madhu @ 2024-09-03 10:07 UTC (permalink / raw)
  To: emacs-devel


* commit  935cc42795686710f82b8928b6802f20be8f27c0
|Author:     Juri Linkov <juri@linkov.net>
|AuthorDate: Mon Mar 28 21:00:32 2022 +0300
|Commit:     Juri Linkov <juri@linkov.net>
|CommitDate: Mon Mar 28 21:00:32 2022 +0300
|    Add search function to search within filenames in Dired and WDired
| (bug#14013)

introduces a variable `wdired-search-replace-filenames' which defaults
to t. When this variable is tured on regexp-replace in wdired buffers is
limited to the visible portion of the buffer.

```
mkdir /dev/shm/test-foo -pv
for i in $(seq 1 40); do ln -sv /foo/$i /dev/shm/test-foo; done
(dired "/dev/shm/test-foo")
(wdired-change-to-wdired-mode)
(replace-regexp "foo" "bar")
```

Only the first screenful of files are operated on.

setting the variable to nil seems to works on the whole buffer. but can
someone explain how this behaviour comes effect?

The relevant code is

```wdired.el: (wdired-change-to-wdired-mode)
  (when wdired-search-replace-filenames
    (add-function :around (local 'isearch-search-fun-function)
                  #'dired-isearch-search-filenames
                  '((isearch-message-prefix . "filename ")))
    (setq-local replace-search-function
                (setq-local replace-re-search-function
                            (funcall isearch-search-fun-function)))
```
and

```wdired.el:(wdired-change-to-dired-mode)
  (when wdired-search-replace-filenames
    (remove-function (local 'isearch-search-fun-function)
                     #'dired-isearch-search-filenames)
    (kill-local-variable 'replace-search-function)
    (kill-local-variable 'replace-re-search-function)
    ;; Restore dired hook
    (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t))
```

Using add-function and remove-function (local) instead of hooks
complicates the debugging, in this case makes it opaque to me.  At what
point does this "implicit narrowing" which results in this behaviour
come into effect?

I set (setq search-highlight nil search-highlight-submatches nil
query-replace-highlight nil query-replace-highlight-submatches nil),
Should I follow up on the the archived bug
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=14013
?




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-04  3:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 10:07 wdired replace-regexp (continue bug 14013?) Madhu
2024-09-03 12:24 ` Michael Heerdegen via Emacs development discussions.
2024-09-03 12:30   ` Michael Heerdegen via Emacs development discussions.
2024-09-04  1:50     ` Madhu
2024-09-04  3:14       ` Michael Heerdegen via Emacs development discussions.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).