all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Mathias Dahl" <mathias.dahl@gmail.com>
To: "Juri Linkov" <juri@jurta.org>, emacs-devel@gnu.org
Subject: Re: isearch in Dired
Date: Thu, 24 Jul 2008 08:41:44 +0200	[thread overview]
Message-ID: <7dbe73ed0807232341n32553520g9c1fa18b99b9b056@mail.gmail.com> (raw)
In-Reply-To: <87r69k2vcw.fsf_-_@jurta.org>

Is the filename property always set or is it just used when this
feature is turned on? If it is always there, does it affect the
performance for large listings? I use Dired a lot and would not like
to have it slower because of a minor feature like this.

2008/7/23, Juri Linkov <juri@jurta.org>:
> Isearch in Dired limited to filenames only is a good feature, so I'd like
> to finish it with the patch below.
>
> The main point is that it doesn't change default Isearch key bindings
> C-s and C-M-s.  It provides two ways to limit Isearch to filenames:
>
> 1. new user option `dired-isearch-filenames'.
>    It is nil by default, but when custimized to non-nil,
>    C-s and C-M-s search only in filenames.
>
> 2. new commands `'dired-do-isearch-filenames' and
>    `dired-do-isearch-regexp-filenames' bound to the
>    keys `M-s f C-s' and `M-s f M-C-s'.
>    Two similar key bindings from another patch are for
>    demonstration purposes: `M-s a C-s' and `M-s a M-C-s'
>    are placed on the same prefix key and they start Isearch
>    in all marked files.
>
> For this feature to work reliably it was necessary to put text
> properties `filename' on file name areas.  Tramp already puts it
> in Tramp buffer, and it seems the `filename' property in all Dired
> buffers doesn't conflict with Tramp.
>
> Index: lisp/dired.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/dired.el,v
> retrieving revision 1.402
> diff -c -r1.402 dired.el
> *** lisp/dired.el	19 Jul 2008 23:55:41 -0000	1.402
> --- lisp/dired.el	23 Jul 2008 20:33:44 -0000
> ***************
> *** 1068,1074 ****
>   		 (dired-move-to-end-of-filename)
>   		 (point))
>   	       '(mouse-face highlight
> ! 		 help-echo "mouse-2: visit this file in other window")))
>   	(error nil))
>         (forward-line 1))))
>
> --- 1068,1075 ----
>   		 (dired-move-to-end-of-filename)
>   		 (point))
>   	       '(mouse-face highlight
> ! 		 help-echo "mouse-2: visit this file in other window"
> ! 		 filename t)))
>   	(error nil))
>         (forward-line 1))))
>
> ***************
> *** 1295,1300 ****
> --- 1297,1307 ----
>       ;; hiding
>       (define-key map "$" 'dired-hide-subdir)
>       (define-key map "\M-$" 'dired-hide-all)
> +     ;; isearch
> +     (define-key map (kbd "M-s a C-s")   'dired-do-isearch-marked-files)
> +     (define-key map (kbd "M-s a M-C-s")
> 'dired-do-isearch-regexp-marked-files)
> +     (define-key map (kbd "M-s f C-s")   'dired-do-isearch-filenames)
> +     (define-key map (kbd "M-s f M-C-s")
> 'dired-do-isearch-regexp-filenames)
>       ;; misc
>       (define-key map "\C-x\C-q" 'dired-toggle-read-only)
>       (define-key map "?" 'dired-summary)
> ***************
> *** 1713,1718 ****
> --- 1720,1726 ----
>     (when (featurep 'dnd)
>       (set (make-local-variable 'dnd-protocol-alist)
>   	 (append dired-dnd-protocol-alist dnd-protocol-alist)))
> +   (add-hook 'isearch-mode-hook 'dired-isearch-filenames-setup nil t)
>     (run-mode-hooks 'dired-mode-hook))
>
>   ;; Idiosyncratic dired commands that don't deal with marks.
>
> Index: lisp/dired-aux.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
> retrieving revision 1.170
> diff -c -r1.170 dired-aux.el
> *** lisp/dired-aux.el	6 May 2008 07:57:30 -0000	1.170
> --- lisp/dired-aux.el	23 Jul 2008 20:33:59 -0000
> ***************
> *** 2273,2281 ****
> --- 2293,2363 ----
>   ;;;###end dired-ins.el
>
>
> + ;; Search only in file names in the Dired buffer.
> +
> + (defcustom dired-isearch-filenames nil
> +   "*If non-nil, Isearch in Dired matches only file names."
> +   :version "23.1"
> +   :type '(choice (const :tag "No restrictions" nil)
> + 		 (const :tag "Isearch only in file names" filename))
> +   :group 'dired)
> +
> + (defvar dired-isearch-orig-success-function nil)
> +
> + (defun dired-isearch-filenames-setup ()
> +   "Set up isearch to search in Dired file names.
> + Intended to be added to `isearch-mode-hook'."
> +   (when dired-isearch-filenames
> +     (setq dired-isearch-orig-success-function
> + 	  (default-value 'isearch-success-function))
> +     (setq-default isearch-success-function
> 'dired-isearch-success-function)
> +     (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
> +
> + (defun dired-isearch-filenames-end ()
> +   "Clean up the Dired file name search after terminating isearch."
> +   (setq-default isearch-success-function
> dired-isearch-orig-success-function)
> +   (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
> +
> + (defun dired-isearch-success-function (beg end)
> +   "Isearch only text that have a property specified in
> `dired-isearch-filenames'."
> +   (and (isearch-success-function-default beg end)
> +        (if dired-isearch-filenames
> + 	   (text-property-not-all (min beg end) (max beg end)
> + 				  'filename nil)
> + 	 t)))
> +
> + ;;;###autoload
> + (defun dired-do-isearch-filenames ()
> +   "Search for a string only in file names in the Dired buffer."
> +   (interactive)
> +   (let ((dired-isearch-filenames t))
> +     (isearch-forward)))
> +
> + ;;;###autoload
> + (defun dired-do-isearch-regexp-filenames ()
> +   "Search for a regexp only in file names in the Dired buffer."
> +   (interactive)
> +   (let ((dired-isearch-filenames t))
> +     (isearch-forward-regexp)))
> +
> +
>   ;; Functions for searching in tags style among marked files.
>
> --
> Juri Linkov
> http://www.jurta.org/emacs/
>
>
>




  reply	other threads:[~2008-07-24  6:41 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-08  3:05 propose: dired-isearch.el --- isearch in Dired William Xu
2007-08-08  3:47 ` Levin
2007-08-08  5:29   ` William Xu
2007-08-08  8:12     ` Herbert Euler
2007-08-08  8:16 ` Miles Bader
2007-08-08  9:35   ` William Xu
2007-08-08 13:01   ` Stefan Monnier
2007-08-09  2:45     ` Miles Bader
2007-08-08 18:46 ` Stefan Monnier
2007-08-08 22:54   ` Juri Linkov
2008-07-23 20:34     ` Juri Linkov
2008-07-24  6:41       ` Mathias Dahl [this message]
2008-07-25  0:32         ` Juri Linkov
2008-07-24 13:53       ` Stefan Monnier
2008-07-24 15:52         ` Drew Adams
2008-07-24 17:20           ` Stefan Monnier
2008-07-24 17:31             ` dired-details status [was: isearch in Dired] Drew Adams
2008-07-25  0:33         ` isearch in Dired Juri Linkov
2008-07-25  0:40           ` Lennart Borgman (gmail)
2008-07-29 15:44             ` word search (Re: isearch in Dired) Juri Linkov
2008-07-29 17:22               ` Chong Yidong
2008-07-30 16:50                 ` Juri Linkov
2008-07-31 12:35                   ` Juri Linkov
2008-07-31 14:10                     ` Stefan Monnier
2008-07-31 15:16                       ` Juri Linkov
2008-07-31 16:30                         ` Stefan Monnier
2008-07-31 15:24                       ` Stefan Monnier
2008-07-29 15:45           ` isearch in Dired Juri Linkov
2008-07-29 17:56             ` Stefan Monnier
2008-07-30 14:29               ` Juri Linkov
2007-08-09  2:46   ` propose: dired-isearch.el --- " William Xu
2007-08-09  0:06 ` Richard Stallman
2007-08-09  1:53   ` William Xu
2007-08-09 23:11     ` Richard Stallman
2007-08-10  1:42       ` William Xu
2007-08-10  8:37         ` Mathias Dahl
2007-08-10  9:22           ` David Kastrup
2007-08-10 15:56           ` Drew Adams
2007-08-11 10:52             ` William Xu
2007-08-11 15:15               ` Drew Adams
2007-08-11 16:58               ` Robert J. Chassell
2007-08-12  1:02                 ` Drew Adams
2007-08-12 20:46               ` Juri Linkov
2007-08-12 21:43                 ` Drew Adams
2007-08-12 23:23                   ` Juri Linkov
2007-08-13  9:14                     ` Mathias Megyei
2007-08-13  9:24                       ` Andreas Schwab
2007-08-13 13:09                         ` Mathias Dahl
2007-08-09 16:07   ` Drew Adams
2007-08-09  2:37 ` Herbert Euler
  -- strict thread matches above, loose matches on Subject: below --
2008-11-08  9:56 Isearch in dired Richard M. Stallman
2008-11-08 10:59 ` Juri Linkov
2008-11-08 11:33   ` Lennart Borgman
2008-11-08 12:23     ` Alan Mackenzie
2008-11-08 15:22       ` Lennart Borgman
2008-11-08 17:07       ` Juri Linkov
2008-11-09  0:26   ` Richard M. Stallman
2008-11-09 21:57     ` Juri Linkov
2008-11-08 12:19 ` Alan Mackenzie
2008-11-08 17:08   ` Juri Linkov
2008-11-08 14:10 ` Chong Yidong
2008-11-08 16:05   ` joakim
2008-11-08 17:27     ` Juri Linkov
2008-11-08 17:17   ` Juri Linkov
2008-11-09  0:26   ` Richard M. Stallman
2008-11-09 14:22 ` Chong Yidong
2008-11-09 15:08   ` Stefan Monnier
2008-11-09 17:59   ` Juri Linkov
2008-11-11 22:55     ` Chong Yidong
2008-11-12  2:59       ` Stefan Monnier
2008-11-12 11:59         ` René Kyllingstad
2008-11-12 15:13           ` Drew Adams
2008-11-12 15:53         ` Richard M. Stallman
2008-11-12  7:55       ` Juri Linkov
2008-11-12 15:08         ` Chong Yidong
2008-11-13 16:57           ` Juri Linkov
2008-11-16 22:22             ` Juri Linkov
2008-11-10  3:11   ` Richard M. Stallman
2008-11-11 21:35     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dbe73ed0807232341n32553520g9c1fa18b99b9b056@mail.gmail.com \
    --to=mathias.dahl@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.