comparison lisp/find-dired.el @ 1225:e16f52a7c9f9

New version from sk. Further hacked: (find-grep-dired): Use ! -type d, not -type f.
author Roland McGrath <roland@gnu.org>
date Sun, 27 Sep 1992 01:24:00 +0000
parents 170e5a18c4ba
children 6314334d7c2b
comparison
equal deleted inserted replaced
1224:981b00f8fe77 1225:e16f52a7c9f9
1 ;; find-dired.el --- run a `find' command and dired the output 1 ;; find-dired.el --- run a `find' command and dired the output
2 2
3 ;;; Copyright (C) 1991 Roland McGrath 3 ;;; Copyright (C) 1992 Free Software Foundation, Inc.
4 4
5 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu> 5 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>,
6 ;; Sebastian Kremer <sk@thp.uni-koeln.de> 6 ;; Sebastian Kremer <sk@thp.uni-koeln.de>
7 ;; Maintainer: Roland McGrath <roland@gnu.ai.mit.edu> 7 ;; Maintainer: Sebastian Kremer <sk@thp.uni-koeln.de>
8 ;; Keywords: unix 8 ;; Keywords: unix
9 9
10 (defconst find-dired-version (substring "$Revision: 1.9 $" 11 -2) 10 (defconst find-dired-version (substring "$Revision: 1.15 $" 11 -2)
11 "$Id: find-dired.el,v 1.9 1991/11/11 13:24:31 sk Exp $") 11 "$Id: find-dired.el,v 1.15 1992/09/26 11:48:45 sk Exp $")
12 12
13 ;;; This program is free software; you can redistribute it and/or modify 13 ;;; This program is free software; you can redistribute it and/or modify
14 ;;; it under the terms of the GNU General Public License as published by 14 ;;; it under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 2, or (at your option) 15 ;;; the Free Software Foundation; either version 1, or (at your option)
16 ;;; any later version. 16 ;;; any later version.
17 ;;; 17 ;;;
18 ;;; This program is distributed in the hope that it will be useful, 18 ;;; This program is distributed in the hope that it will be useful,
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; 22 ;;;
23 ;;; A copy of the GNU General Public License can be obtained from this 23 ;;; A copy of the GNU General Public License can be obtained from this
24 ;;; program's author (send electronic mail to roland@ai.mit.edu) or from 24 ;;; program's author (send electronic mail to roland@ai.mit.edu) or from
25 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 25 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
26 ;;; 02139, USA. 26 ;;; 02139, USA.
27 ;;;
27 28
28 ;;; Commentary: 29 ;;; Commentary:
30
31 ;; LISPDIR ENTRY for the Elisp Archive ===============================
32 ;; LCD Archive Entry:
33 ;; find-dired|Roland McGrath, Sebastian Kremer
34 ;; |roland@gnu.ai.mit.edu, sk@thp.uni-koeln.de
35 ;; |Run a `find' command and dired the output
36 ;; |$Date: 1992/09/26 11:48:45 $|$Revision: 1.15 $|
29 37
30 ;; INSTALLATION ====================================================== 38 ;; INSTALLATION ======================================================
31 39
32 ;; To use this file, byte-compile it, install it somewhere in your 40 ;; To use this file, byte-compile it, install it somewhere in your
33 ;; load-path, and put: 41 ;; load-path, and put:
47 ;; in your ~/.emacs. 55 ;; in your ~/.emacs.
48 56
49 ;;; Code: 57 ;;; Code:
50 58
51 (require 'dired) 59 (require 'dired)
60
52 ;;;###autoload 61 ;;;###autoload
53 (defvar find-ls-option (if (eq system-type 'berkeley-unix) "-ls" 62 (defvar find-ls-option (if (eq system-type 'berkeley-unix) "-ls"
54 "-exec ls -ldi {} \\;") 63 "-exec ls -ldi {} \\;")
55 "*Option to `find' to produce an `ls -l'-type listing.") 64 "*Option to `find' to produce an `ls -l'-type listing.")
56 65
85 (widen) 94 (widen)
86 (kill-all-local-variables) 95 (kill-all-local-variables)
87 (setq buffer-read-only nil) 96 (setq buffer-read-only nil)
88 (erase-buffer) 97 (erase-buffer)
89 (setq default-directory dir 98 (setq default-directory dir
90 find-args args 99 find-args args ; save for next interactive call
91 args (concat "find . " (if (string= args "") "" 100 args (concat "find . "
92 (concat "\\( " args " \\) ")) find-ls-option)) 101 (if (string= args "")
93 (dired-mode dir "-gils");; find(1)'s -ls corresponds to `ls -gilds' 102 ""
94 ;; (but we don't want -d, of course) 103 (concat "\\( " args " \\) "))
95 ;; Set subdir-alist so that Tree Dired will work (but STILL NOT with 104 find-ls-option))
96 ;; dired-nstd.el): 105 ;; The next statement will bomb in classic dired (no optional arg allowed)
97 (set (make-local-variable 'dired-subdir-alist) 106 ;; find(1)'s -ls corresponds to these switches.
98 (list (cons default-directory (point-marker)))) ; we are at point-min 107 ;; Note -b, at least GNU find quotes spaces etc. in filenames
108 (dired-mode dir "-gilsb")
109 ;; Set subdir-alist so that Tree Dired will work:
110 (if (fboundp 'dired-simple-subdir-alist)
111 ;; will work even with nested dired format (dired-nstd.el,v 1.15
112 ;; and later)
113 (dired-simple-subdir-alist)
114 ;; else we have an ancient tree dired (or classic dired, where
115 ;; this does no harm)
116 (set (make-local-variable 'dired-subdir-alist)
117 (list (cons default-directory (point-min-marker)))))
99 (setq buffer-read-only nil) 118 (setq buffer-read-only nil)
100 ;; Subdir headlerline must come first because the first marker in 119 ;; Subdir headlerline must come first because the first marker in
101 ;; subdir-alist points there. 120 ;; subdir-alist points there.
102 (insert " " dir ":\n") 121 (insert " " dir ":\n")
103 ;; Make second line a ``find'' line in analogy to the ``total'' or 122 ;; Make second line a ``find'' line in analogy to the ``total'' or
140 Thus ARG can also contain additional grep options." 159 Thus ARG can also contain additional grep options."
141 (interactive "DFind-grep (directory): \nsFind-grep (grep args): ") 160 (interactive "DFind-grep (directory): \nsFind-grep (grep args): ")
142 ;; find -exec doesn't allow shell i/o redirections in the command, 161 ;; find -exec doesn't allow shell i/o redirections in the command,
143 ;; or we could use `grep -l >/dev/null' 162 ;; or we could use `grep -l >/dev/null'
144 (find-dired dir 163 (find-dired dir
145 (concat "-exec grep " find-grep-options " " args " {} \\\; "))) 164 (concat "! -type d -exec grep " find-grep-options " "
165 args " {} \\\; ")))
146 166
147 (defun find-dired-filter (proc string) 167 (defun find-dired-filter (proc string)
148 ;; Filter for \\[find-dired] processes. 168 ;; Filter for \\[find-dired] processes.
149 (dired-log "``%s''\n" string)
150 (let ((buf (process-buffer proc))) 169 (let ((buf (process-buffer proc)))
151 (if (buffer-name buf) ; not killed? 170 (if (buffer-name buf) ; not killed?
152 (save-excursion 171 (save-excursion
153 (set-buffer buf) 172 (set-buffer buf)
154 (save-restriction 173 (save-restriction
180 (save-excursion 199 (save-excursion
181 (set-buffer buf) 200 (set-buffer buf)
182 (setq mode-line-process nil) 201 (setq mode-line-process nil)
183 (message "find-dired %s finished." (current-buffer)))))) 202 (message "find-dired %s finished." (current-buffer))))))
184 203
204 (or (fboundp 'start-process-shell-command)
205 ;; From version 19 subr.el.
206 (defun start-process-shell-command (name buffer &rest args)
207 "Start a program in a subprocess. Return the process object for it.
208 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS.
209 NAME is name for process. It is modified if necessary to make it unique.
210 BUFFER is the buffer or (buffer-name) to associate with the process.
211 Process output goes at end of that buffer, unless you specify
212 an output stream or filter function to handle the output.
213 BUFFER may be also nil, meaning that this process is not associated
214 with any buffer
215 Third arg is command name, the name of a shell command.
216 Remaining arguments are the arguments for the command.
217 Wildcards and redirection are handle as usual in the shell."
218 (if (eq system-type 'vax-vms)
219 (apply 'start-process name buffer args)
220 (start-process name buffer shell-file-name "-c"
221 (concat "exec " (mapconcat 'identity args " "))))))
222
185 (provide 'find-dired) 223 (provide 'find-dired)
186 224
187 ;;; find-dired.el ends here 225 ;;; find-dired.el ends here