annotate lisp/find-dired.el @ 430:62d4447676c1

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Sat, 09 Nov 1991 01:34:02 +0000
parents 97aa6a6f9aa5
children c3bbd755b7da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1 ;;; find-dired.el -- Run a `find' command and dired the result.
294
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
2 ;;; Copyright (C) 1991 Roland McGrath
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
3
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
4 (defconst find-dired-version "$Id: find-dired.el,v 1.7 1991/06/20 08:50:20 sk RelBeta $")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
5
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
6 ;;; This program is free software; you can redistribute it and/or modify
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
7 ;;; it under the terms of the GNU General Public License as published by
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
8 ;;; the Free Software Foundation; either version 1, or (at your option)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
9 ;;; any later version.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
10 ;;;
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
11 ;;; This program is distributed in the hope that it will be useful,
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
14 ;;; GNU General Public License for more details.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
15 ;;;
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
16 ;;; A copy of the GNU General Public License can be obtained from this
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
17 ;;; program's author (send electronic mail to roland@ai.mit.edu) or from
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
18 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
19 ;;; 02139, USA.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
20 ;;;
294
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
21 ;;; Send bug reports to roland@gnu.ai.mit.edu.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
22
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
23 ;;; To use this file, byte-compile it, install it somewhere
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
24 ;;; in your load-path, and put:
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
25 ;;; (autoload 'find-dired "find-dired" nil t)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
26 ;;; (autoload 'lookfor-dired "find-dired" nil t)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
27 ;;; in your .emacs, or site-init.el, etc.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
28 ;;; To bind it to a key, put, e.g.:
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
29 ;;; (global-set-key "\C-cf" 'find-dired)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
30 ;;; (global-set-key "\C-cl" 'lookfor-dired)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
31 ;;; in your .emacs.
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
32
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
33 (require 'dired)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
34
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
35 (defvar find-args nil
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
36 "Last arguments given to `find' by \\[find-dired].")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
37
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
38 (defvar find-ls-option (if (eq system-type 'berkeley-unix) "-ls"
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
39 "-exec ls -ldi {} \\;")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
40 "Option to `find' to produce an `ls -l'-type listing.")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
41
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
42 ;;;###autoload
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
43 (defun find-dired (dir args)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
44 "Run `find' and go into dired-mode on a buffer of the output.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
45 The command run is \"find . \\( ARGS \\) -ls\" (after changing into DIR)."
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
46 (interactive (list (read-file-name "Run find in directory: " nil "" t)
294
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
47 (if (featurep 'gmhist)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
48 (read-with-history-in 'find-args-history
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
49 "Run find (with args): ")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
50 (read-string "Run find (with args): " find-args))))
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
51 (if (equal dir "")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
52 (setq dir default-directory))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
53 ;; Expand DIR, and make sure it has a trailing slash.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
54 (setq dir (file-name-as-directory (expand-file-name dir)))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
55 ;; Check that it's really a directory.
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
56 (or (file-directory-p dir)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
57 (error "%s is not a directory!" dir))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
58 (switch-to-buffer (get-buffer-create "*Find*"))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
59 (widen)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
60 (kill-all-local-variables)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
61 (setq buffer-read-only nil)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
62 (erase-buffer)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
63 (setq default-directory dir
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
64 find-args args
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
65 args (concat "find . " (if (string= args "") ""
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
66 (concat "\\( " args " \\) ")) find-ls-option))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
67 (insert " " args "\n"
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
68 " " dir ":\n")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
69 (set-process-filter (start-process-shell-command "find"
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
70 (current-buffer) args)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
71 'find-dired-filter)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
72 (set-process-sentinel (get-buffer-process (current-buffer))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
73 'find-dired-sentinel)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
74 (dired-mode)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
75 (setq mode-line-process '(": %s")))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
76
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
77 ;;;###autoload
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
78 (defun find-name-dired (dir pattern)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
79 "Search DIR recursively for files matching the globbing pattern PATTERN,
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
80 and run dired on those files."
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
81 (interactive "DSearch directory: \nsSearch directory %s for: ")
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
82 (find-dired dir (concat "-name '" pattern "'")))
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
83
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
84 (defun find-dired-filter (proc string)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
85 ;; Filter for \\[find-dired] processes.
294
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
86 (let ((buf (process-buffer proc)))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
87 (if (buffer-name buf) ; not killed?
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
88 (save-excursion
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
89 (set-buffer buf)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
90 (save-restriction
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
91 (widen)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
92 (save-excursion
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
93 (let ((buffer-read-only nil)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
94 (end (point-max)))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
95 (goto-char end)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
96 (insert string)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
97 (goto-char end)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
98 (or (looking-at "^")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
99 (forward-line 1))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
100 (while (looking-at "^")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
101 (insert " ")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
102 (forward-line 1))))))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
103 ;; The buffer has been killed.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
104 (delete-process proc))))
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
105
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
106 (defun find-dired-sentinel (proc state)
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
107 ;; Sentinel for \\[find-dired] processes.
294
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
108 (let ((buf (process-buffer proc)))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
109 (if (buffer-name buf)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
110 (save-excursion
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
111 (set-buffer buf)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
112 (setq mode-line-process nil)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
113 (message "find-dired %s finished." (current-buffer))))))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
114
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
115 (or (fboundp 'start-process-shell-command)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
116 ;; From version 19 subr.el.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
117 (defun start-process-shell-command (name buffer &rest args)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
118 "Start a program in a subprocess. Return the process object for it.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
119 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
120 NAME is name for process. It is modified if necessary to make it unique.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
121 BUFFER is the buffer or (buffer-name) to associate with the process.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
122 Process output goes at end of that buffer, unless you specify
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
123 an output stream or filter function to handle the output.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
124 BUFFER may be also nil, meaning that this process is not associated
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
125 with any buffer
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
126 Third arg is command name, the name of a shell command.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
127 Remaining arguments are the arguments for the command.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
128 Wildcards and redirection are handle as usual in the shell."
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
129 (if (eq system-type 'vax-vms)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
130 (apply 'start-process name buffer args)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
131 (start-process name buffer shell-file-name "-c"
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
132 (concat "exec " (mapconcat 'identity args " ")))))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
133 )
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
134
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
135 ;; From: oblanc@watcgl.waterloo.edu (Olivier Blanc)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
136 ;; Subject: find-dired, lookfor-dired
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
137 ;; Date: 10 May 91 17:50:00 GMT
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
138 ;; Organization: University of Waterloo
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
139
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
140 ;; I added a functiopn to the find-dired.el file:
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
141 ;; The function is a lookfor-dired and is used to search a string
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
142 ;; a subtree:
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
143
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
144 ;;;###autoload
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
145 (defun lookfor-dired (dir args)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
146 "Find files in DIR containing a regexp ARG and go into dired-mode on the output.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
147 The command run is
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
148
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
149 \"find . -exec grep -l ARG {} \\\; -ls\"
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
150
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
151 \(after changing into DIR)."
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
152 (interactive (list (read-file-name "Run find in directory: " nil "" t)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
153 (read-string "Run find (with args): " find-args)))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
154 (if (equal dir "")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
155 (setq dir default-directory))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
156 ;; Expand DIR, and make sure it has a trailing slash.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
157 (setq dir (file-name-as-directory (expand-file-name dir)))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
158 ;; Check that it's really a directory.
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
159 (or (file-directory-p dir)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
160 (error "%s is not a directory!" dir))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
161 (switch-to-buffer (get-buffer-create "*Find*"))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
162 (widen)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
163 (kill-all-local-variables)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
164 (setq buffer-read-only nil)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
165 (erase-buffer)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
166 (setq default-directory dir
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
167 find-args args
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
168 args (concat "find . -exec grep -l " args " {} \\\; -ls"))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
169 (insert " " args "\n"
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
170 " " dir ":\n")
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
171 (set-process-filter (start-process-shell-command "find"
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
172 (current-buffer) args)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
173 'find-dired-filter)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
174 (set-process-sentinel (get-buffer-process (current-buffer))
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
175 'find-dired-sentinel)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
176 (dired-mode)
97aa6a6f9aa5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 292
diff changeset
177 (setq mode-line-process '(": %s")))
292
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
178
cab78578e745 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
179 (provide 'find-dired)