From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Mathias Dahl" Newsgroups: gmane.emacs.devel Subject: Re: isearch in Dired Date: Thu, 24 Jul 2008 08:41:44 +0200 Message-ID: <7dbe73ed0807232341n32553520g9c1fa18b99b9b056@mail.gmail.com> References: <874pjaiv45.fsf@gmail.com> <87lkclekep.fsf@jurta.org> <87r69k2vcw.fsf_-_@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216881720 32621 80.91.229.12 (24 Jul 2008 06:42:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jul 2008 06:42:00 +0000 (UTC) To: "Juri Linkov" , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 24 08:42:49 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KLuXI-0003Vl-C0 for ged-emacs-devel@m.gmane.org; Thu, 24 Jul 2008 08:42:49 +0200 Original-Received: from localhost ([127.0.0.1]:59952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLuWO-0002RW-Nh for ged-emacs-devel@m.gmane.org; Thu, 24 Jul 2008 02:41:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLuWJ-0002Pa-OY for emacs-devel@gnu.org; Thu, 24 Jul 2008 02:41:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLuWI-0002NP-7i for emacs-devel@gnu.org; Thu, 24 Jul 2008 02:41:46 -0400 Original-Received: from [199.232.76.173] (port=49952 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLuWI-0002NA-1s for emacs-devel@gnu.org; Thu, 24 Jul 2008 02:41:46 -0400 Original-Received: from wr-out-0506.google.com ([64.233.184.227]:6331) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KLuWI-0005Dv-8n for emacs-devel@gnu.org; Thu, 24 Jul 2008 02:41:46 -0400 Original-Received: by wr-out-0506.google.com with SMTP id c30so1711853wra.14 for ; Wed, 23 Jul 2008 23:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=g+RrsxmiQILEj0iCbk6IXloCbeD1TdPNca8fgkDqBbc=; b=VOFxkwXiHrq9uy046gwbemQVc1JZWhf4iIv/992Fj2lTlBP7ejQNxXgOwrfjYPA+vP Hi9uSj8wnRZkEukDlkIRwfE79t/KlMNkX7MN9pOJI/aO4nLYzPBoDqtFESWWHWewx/1M dNlX/ohpHVubCXBzjFJ5nznl3Xrc1hva+lAmo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gf/C97axP/DQAmhZI2LBK7PjAZim2IZF5uDaBVihvnvWdy4wE1cJ+osiRpPDRl8Mnk W6y38rpf7LebIFAHWxKksatrBi1gW4cqFGKm76B9WGStdNYAQSJkrthRs0J20wMmxeuh NmEmH1OzLQ4PP1LGEm+t5ftzvF/5jYG519RGo= Original-Received: by 10.90.56.5 with SMTP id e5mr1005480aga.80.1216881704515; Wed, 23 Jul 2008 23:41:44 -0700 (PDT) Original-Received: by 10.150.195.5 with HTTP; Wed, 23 Jul 2008 23:41:44 -0700 (PDT) In-Reply-To: <87r69k2vcw.fsf_-_@jurta.org> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:101372 Archived-At: 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 : > 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/ > > >