aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1995-03-06 19:55:47 +0000
committerRoland McGrath1995-03-06 19:55:47 +0000
commit347cd536de4bb12a59ac2f9ff4585b4b4c262035 (patch)
tree800f4273cb703f17e36e37a91822358a7c63f11a
parent20c1daecbc0dc4a0cc26fb38120c5e517dc46503 (diff)
downloademacs-347cd536de4bb12a59ac2f9ff4585b4b4c262035.tar.gz
emacs-347cd536de4bb12a59ac2f9ff4585b4b4c262035.zip
(find-ls-option): Doc fix: now a cons.
(find-dired): Initialize the process-mark for the filter to use. Find listing switches in cdr of find-ls-option. (find-dired-filter): Use dired-insert-set-properties on new text.
-rw-r--r--lisp/find-dired.el71
1 files changed, 38 insertions, 33 deletions
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 71958d8af63..04577c4e6f5 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -1,18 +1,17 @@
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) 1992, 1994 Free Software Foundation, Inc. 3;;; Copyright (C) 1992, 1994, 1995 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: Sebastian Kremer <sk@thp.uni-koeln.de>
8;; Keywords: unix 7;; Keywords: unix
9 8
10(defconst find-dired-version (substring "$Revision: 1.17 $" 11 -2) 9(defconst find-dired-version (substring "$Revision: 1.18 $" 11 -2)
11 "$Id: find-dired.el,v 1.17 1994/11/19 14:03:23 rms Exp rms $") 10 "$Id: find-dired.el,v 1.18 1994/12/15 12:16:29 rms Exp roland $")
12 11
13;;; This program is free software; you can redistribute it and/or modify 12;;; 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 13;;; it under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 1, or (at your option) 14;;; the Free Software Foundation; either version 2, or (at your option)
16;;; any later version. 15;;; any later version.
17;;; 16;;;
18;;; This program is distributed in the hope that it will be useful, 17;;; This program is distributed in the hope that it will be useful,
@@ -33,7 +32,7 @@
33;; find-dired|Roland McGrath, Sebastian Kremer 32;; find-dired|Roland McGrath, Sebastian Kremer
34;; |roland@gnu.ai.mit.edu, sk@thp.uni-koeln.de 33;; |roland@gnu.ai.mit.edu, sk@thp.uni-koeln.de
35;; |Run a `find' command and dired the output 34;; |Run a `find' command and dired the output
36;; |$Date: 1994/11/19 14:03:23 $|$Revision: 1.17 $| 35;; |$Date: 1994/12/15 12:16:29 $|$Revision: 1.18 $|
37 36
38;; INSTALLATION ====================================================== 37;; INSTALLATION ======================================================
39 38
@@ -58,10 +57,15 @@
58 57
59(require 'dired) 58(require 'dired)
60 59
60;; find(1)'s -ls corresponds to these switches.
61;; Note -b, at least GNU find quotes spaces etc. in filenames
61;;;###autoload 62;;;###autoload
62(defvar find-ls-option (if (eq system-type 'berkeley-unix) "-ls" 63(defvar find-ls-option (if (eq system-type 'berkeley-unix) '("-ls" . "-gilsb")
63 "-exec ls -ld {} \\;") 64 '("-exec ls -ld {} \\;" . "-ld"))
64 "*Option to `find' to produce an `ls -l'-type listing.") 65 "*Description of the option to `find' to produce an `ls -l'-type listing.
66This is a cons of two strings (FIND-OPTION . LS-SWITCHES). FIND-OPTION
67gives the option (or options) to `find' that produce the desired output.
68LS-SWITCHES is a list of `ls' switches to tell dired how to parse the output.")
65 69
66;;;###autoload 70;;;###autoload
67(defvar find-grep-options (if (eq system-type 'berkeley-unix) "-s" "-q") 71(defvar find-grep-options (if (eq system-type 'berkeley-unix) "-s" "-q")
@@ -72,6 +76,9 @@ On other systems, the closest you can come is to use `-l'.")
72(defvar find-args nil 76(defvar find-args nil
73 "Last arguments given to `find' by \\[find-dired].") 77 "Last arguments given to `find' by \\[find-dired].")
74 78
79;; History of find-args values entered in the minibuffer.
80(defvar find-args-history nil)
81
75;;;###autoload 82;;;###autoload
76(defun find-dired (dir args) 83(defun find-dired (dir args)
77 "Run `find' and go into dired-mode on a buffer of the output. 84 "Run `find' and go into dired-mode on a buffer of the output.
@@ -79,10 +86,8 @@ The command run (after changing into DIR) is
79 86
80 find . \\( ARGS \\) -ls" 87 find . \\( ARGS \\) -ls"
81 (interactive (list (read-file-name "Run find in directory: " nil "" t) 88 (interactive (list (read-file-name "Run find in directory: " nil "" t)
82 (if (featurep 'gmhist) 89 (read-string "Run find (with args): " find-args
83 (read-with-history-in 'find-args-history 90 '(find-args-history . 1))))
84 "Run find (with args): ")
85 (read-string "Run find (with args): " find-args))))
86 ;; Expand DIR ("" means default-directory), and make sure it has a 91 ;; Expand DIR ("" means default-directory), and make sure it has a
87 ;; trailing slash. 92 ;; trailing slash.
88 (setq dir (file-name-as-directory (expand-file-name dir))) 93 (setq dir (file-name-as-directory (expand-file-name dir)))
@@ -100,20 +105,11 @@ The command run (after changing into DIR) is
100 (if (string= args "") 105 (if (string= args "")
101 "" 106 ""
102 (concat "\\( " args " \\) ")) 107 (concat "\\( " args " \\) "))
103 find-ls-option)) 108 (car find-ls-option)))
104 ;; The next statement will bomb in classic dired (no optional arg allowed) 109 ;; The next statement will bomb in classic dired (no optional arg allowed)
105 ;; find(1)'s -ls corresponds to these switches. 110 (dired-mode dir (cdr find-ls-option))
106 ;; Note -b, at least GNU find quotes spaces etc. in filenames
107 (dired-mode dir "-gilsb")
108 ;; Set subdir-alist so that Tree Dired will work: 111 ;; Set subdir-alist so that Tree Dired will work:
109 (if (fboundp 'dired-simple-subdir-alist) 112 (dired-simple-subdir-alist)
110 ;; will work even with nested dired format (dired-nstd.el,v 1.15
111 ;; and later)
112 (dired-simple-subdir-alist)
113 ;; else we have an ancient tree dired (or classic dired, where
114 ;; this does no harm)
115 (set (make-local-variable 'dired-subdir-alist)
116 (list (cons default-directory (point-min-marker)))))
117 (setq buffer-read-only nil) 113 (setq buffer-read-only nil)
118 ;; Subdir headlerline must come first because the first marker in 114 ;; Subdir headlerline must come first because the first marker in
119 ;; subdir-alist points there. 115 ;; subdir-alist points there.
@@ -121,12 +117,12 @@ The command run (after changing into DIR) is
121 ;; Make second line a ``find'' line in analogy to the ``total'' or 117 ;; Make second line a ``find'' line in analogy to the ``total'' or
122 ;; ``wildcard'' line. 118 ;; ``wildcard'' line.
123 (insert " " args "\n") 119 (insert " " args "\n")
124 ;; Start the find process 120 ;; Start the find process.
125 (set-process-filter (start-process-shell-command "find" 121 (let ((proc (start-process-shell-command "find" (current-buffer) args)))
126 (current-buffer) args) 122 (set-process-filter proc (function find-dired-filter))
127 (function find-dired-filter)) 123 (set-process-sentinel proc (function find-dired-sentinel))
128 (set-process-sentinel (get-buffer-process (current-buffer)) 124 ;; Initialize the process marker; it is used by the filter.
129 (function find-dired-sentinel)) 125 (move-marker (process-mark proc) 1 (current-buffer)))
130 (setq mode-line-process '(":%s"))) 126 (setq mode-line-process '(":%s")))
131 127
132;;;###autoload 128;;;###autoload
@@ -184,10 +180,19 @@ Thus ARG can also contain additional grep options."
184 (forward-line 1)) 180 (forward-line 1))
185 ;; Convert ` ./FILE' to ` FILE' 181 ;; Convert ` ./FILE' to ` FILE'
186 ;; This would lose if the current chunk of output 182 ;; This would lose if the current chunk of output
187 ;; starts or ends within the ` ./', so backup up a bit: 183 ;; starts or ends within the ` ./', so back up a bit:
188 (goto-char (- end 3)) ; no error if < 0 184 (goto-char (- end 3)) ; no error if < 0
189 (while (search-forward " ./" nil t) 185 (while (search-forward " ./" nil t)
190 (delete-region (point) (- (point) 2))))))) 186 (delete-region (point) (- (point) 2)))
187 ;; Find all the complete lines in the unprocessed
188 ;; output and process it to add text properties.
189 (goto-char end)
190 (if (search-backward "\n" (process-mark proc) t)
191 (progn
192 (dired-insert-set-properties (process-mark proc)
193 (1+ (point)))
194 (move-marker (process-mark proc) (1+ (point)))))
195 ))))
191 ;; The buffer has been killed. 196 ;; The buffer has been killed.
192 (delete-process proc)))) 197 (delete-process proc))))
193 198