[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: propose: dired-isearch.el --- isearch in Dired

From: Juri Linkov
Subject: Re: propose: dired-isearch.el --- isearch in Dired
Date: Thu, 09 Aug 2007 01:54:38 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

I think using isearch in Dired to match only at filenames is a very good idea.

> Actually all the search funs can be collapsed into one:
>    (defun dired-isearch-search-fun-function () 'dired-isearch-search)
>    (defun dired-isearch-search (&rest args)
>      (let ((fun (let ((isearch-search-fun-function nil))
>                   (isearch-search-fun)))
>            ret)
>        (while (and (setq ret (apply fun args))
>                    ;; Use `help-echo' instead of `dired-filename' so as to
>                    ;; also work in Tramp dired buffers.
>                    (not (get-text-property (1- point) 'help-echo)))
>          (forward-char 1))
>        ret))

With patches (uninstalled due to feature freeze) from the thread
this implementation can be collapsed even more:

    (set (make-local-variable 'isearch-success-function)
         (lambda () (get-text-property (1- point) 'help-echo)))

or with a new function `dired-pos-in-filename-p':

    (set (make-local-variable 'isearch-success-function)

> But there are two problems left:
> 1 - find a UI for it: just providing N new commands doesn't seem good enough.
>     Maybe just something like:
>     (define-minor-mode dired-isearch-filenames-mode
>       "Only match filenames in isearch."
>       (if dired-isearch-filenames-mode
>           (set (make-local-variable 'isearch-search-fun-function)
>                'dired-isearch-search-fun-function)
>         (kill-local-variable 'isearch-search-fun-function)))
>     and then bind it to a key?

And to use the same key to activate other links-only searches like on
links in Info (filenames in dired buffers are links too).

> 2 - checking `help-echo' is bound to get us into trouble when we add
>     help-echo to other elements such as access right bits, etc...
>     We really should check `dired-filename'.  And if that doesn't work,
>     let's fix it so that it does.  And/or add a dired-pos-in-filename-p
>     predicate to abstract over it.

Juri Linkov

reply via email to

[Prev in Thread] Current Thread [Next in Thread]