After seeing this post and one of its comments, I am trying to implement the following convenient search pattern in dired
:
- Press
C-s
to startisearch
- Type the substring I am looking for
- Possibly jump between all matching results by typing
C-s
repeatedly - Press the "Enter" key to enter the file (or folder) highlighted by
isearch
I'm doing it with the following snippet:
(add-hook 'isearch-mode-end-hook
(lambda ()
(when (and (eq major-mode 'dired-mode)
(not isearch-mode-end-hook-quit)
(eq last-input-event ?\r)
)
(dired-find-file))))
Unfortunately the (eq last-input-event ?\r)
bit does not appear to work: pressing "Enter" just exits isearch
(default behavior), and I have to press it again to enter the file. For some reason ?\r
does not capture my "Enter" key. To verify this is not caused by some other part of my emacs
configuration I deactivated most of it, but to no avail.
Additionally, I would be interested to hear whether there is some other approach to search files in dired
which convenience can be comparable to the one described above.