diff options
| author | Peter Breton | 2000-10-04 04:19:10 +0000 |
|---|---|---|
| committer | Peter Breton | 2000-10-04 04:19:10 +0000 |
| commit | 82d11a0b0e66b7e36df397c7c28ea9b1f7c755b6 (patch) | |
| tree | 44a561ecb3735b21143079abccc134458539af0f | |
| parent | b442e70a76980099c58dae2bfd11335b69664c3b (diff) | |
| download | emacs-82d11a0b0e66b7e36df397c7c28ea9b1f7c755b6.tar.gz emacs-82d11a0b0e66b7e36df397c7c28ea9b1f7c755b6.zip | |
* find-lisp.el (find-lisp-find-files-internal):
Make sure directory name ends with "/".
| -rw-r--r-- | lisp/find-lisp.el | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/lisp/find-lisp.el b/lisp/find-lisp.el index 0398bd6e0ec..e865d29ca67 100644 --- a/lisp/find-lisp.el +++ b/lisp/find-lisp.el | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;; Author: Peter Breton | 3 | ;; Author: Peter Breton |
| 4 | ;; Created: Fri Mar 26 1999 | 4 | ;; Created: Fri Mar 26 1999 |
| 5 | ;; Keywords: unix | 5 | ;; Keywords: unix |
| 6 | ;; Time-stamp: <1999-04-19 16:37:01 pbreton> | 6 | ;; Time-stamp: <2000-10-04 00:17:29 pbreton> |
| 7 | 7 | ||
| 8 | ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. | 8 | ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
| 9 | 9 | ||
| @@ -36,7 +36,7 @@ | |||
| 36 | ;; user-level functions, and perhaps use some kind of forms interface | 36 | ;; user-level functions, and perhaps use some kind of forms interface |
| 37 | ;; for medium-level queries. Really complicated queries can be | 37 | ;; for medium-level queries. Really complicated queries can be |
| 38 | ;; expressed in Lisp. | 38 | ;; expressed in Lisp. |
| 39 | ;; | 39 | ;; |
| 40 | 40 | ||
| 41 | ;;; Todo | 41 | ;;; Todo |
| 42 | ;; | 42 | ;; |
| @@ -83,7 +83,7 @@ | |||
| 83 | "True if DIR is not a dot file, and not a symlink. | 83 | "True if DIR is not a dot file, and not a symlink. |
| 84 | PARENT is the parent directory of DIR." | 84 | PARENT is the parent directory of DIR." |
| 85 | (and find-lisp-debug | 85 | (and find-lisp-debug |
| 86 | (find-lisp-debug-message | 86 | (find-lisp-debug-message |
| 87 | (format "Processing directory %s in %s" dir parent))) | 87 | (format "Processing directory %s in %s" dir parent))) |
| 88 | ;; Skip current and parent directories | 88 | ;; Skip current and parent directories |
| 89 | (not (or (string= dir ".") | 89 | (not (or (string= dir ".") |
| @@ -96,7 +96,7 @@ PARENT is the parent directory of DIR." | |||
| 96 | "True if FILE matches `find-lisp-regexp'. | 96 | "True if FILE matches `find-lisp-regexp'. |
| 97 | DIR is the directory containing FILE." | 97 | DIR is the directory containing FILE." |
| 98 | (and find-lisp-debug | 98 | (and find-lisp-debug |
| 99 | (find-lisp-debug-message | 99 | (find-lisp-debug-message |
| 100 | (format "Processing file %s in %s" file dir))) | 100 | (format "Processing file %s in %s" file dir))) |
| 101 | (and (not (file-directory-p (expand-file-name file dir))) | 101 | (and (not (file-directory-p (expand-file-name file dir))) |
| 102 | (string-match find-lisp-regexp file))) | 102 | (string-match find-lisp-regexp file))) |
| @@ -105,7 +105,7 @@ DIR is the directory containing FILE." | |||
| 105 | "True if FILE is a directory. | 105 | "True if FILE is a directory. |
| 106 | Argument DIR is the directory containing FILE." | 106 | Argument DIR is the directory containing FILE." |
| 107 | (and find-lisp-debug | 107 | (and find-lisp-debug |
| 108 | (find-lisp-debug-message | 108 | (find-lisp-debug-message |
| 109 | (format "Processing file %s in %s" file dir))) | 109 | (format "Processing file %s in %s" file dir))) |
| 110 | (and (file-directory-p (expand-file-name file dir)) | 110 | (and (file-directory-p (expand-file-name file dir)) |
| 111 | (not (or (string= file ".") | 111 | (not (or (string= file ".") |
| @@ -121,20 +121,22 @@ Argument DIR is the directory containing FILE." | |||
| 121 | (directory-predicate 'find-lisp-default-directory-predicate) | 121 | (directory-predicate 'find-lisp-default-directory-predicate) |
| 122 | (find-lisp-regexp regexp) | 122 | (find-lisp-regexp regexp) |
| 123 | ) | 123 | ) |
| 124 | (find-lisp-find-files-internal | 124 | (find-lisp-find-files-internal |
| 125 | directory | 125 | directory |
| 126 | file-predicate | 126 | file-predicate |
| 127 | directory-predicate))) | 127 | directory-predicate))) |
| 128 | 128 | ||
| 129 | ;; Workhorse function | 129 | ;; Workhorse function |
| 130 | (defun find-lisp-find-files-internal (directory file-predicate | 130 | (defun find-lisp-find-files-internal (directory file-predicate |
| 131 | directory-predicate) | 131 | directory-predicate) |
| 132 | "Find files under DIRECTORY which satisfy FILE-PREDICATE. | 132 | "Find files under DIRECTORY which satisfy FILE-PREDICATE. |
| 133 | FILE-PREDICATE is a function which takes two arguments: the file and its | 133 | FILE-PREDICATE is a function which takes two arguments: the file and its |
| 134 | directory. | 134 | directory. |
| 135 | 135 | ||
| 136 | DIRECTORY-PREDICATE is used to decide whether to descend into directories. | 136 | DIRECTORY-PREDICATE is used to decide whether to descend into directories. |
| 137 | It is a function which takes two arguments, the directory and its parent." | 137 | It is a function which takes two arguments, the directory and its parent." |
| 138 | (or (string-match "/$" directory) | ||
| 139 | (setq directory (concat directory "/"))) | ||
| 138 | (let (results sub-results) | 140 | (let (results sub-results) |
| 139 | (mapcar | 141 | (mapcar |
| 140 | (function | 142 | (function |
| @@ -148,15 +150,15 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 148 | (progn | 150 | (progn |
| 149 | (setq sub-results | 151 | (setq sub-results |
| 150 | (find-lisp-find-files-internal | 152 | (find-lisp-find-files-internal |
| 151 | fullname | 153 | fullname |
| 152 | file-predicate | 154 | file-predicate |
| 153 | directory-predicate)) | 155 | directory-predicate)) |
| 154 | (if results | 156 | (if results |
| 155 | (nconc results sub-results) | 157 | (nconc results sub-results) |
| 156 | (setq results sub-results)))) | 158 | (setq results sub-results)))) |
| 157 | ;; For all files and directories, call the file predicate | 159 | ;; For all files and directories, call the file predicate |
| 158 | (and (funcall file-predicate file directory) | 160 | (and (funcall file-predicate file directory) |
| 159 | (if results | 161 | (if results |
| 160 | (nconc results (list fullname)) | 162 | (nconc results (list fullname)) |
| 161 | (setq results (list fullname)))) | 163 | (setq results (list fullname)))) |
| 162 | ))))) | 164 | ))))) |
| @@ -188,8 +190,8 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 188 | "*Find Lisp Dired Subdirectories*")) | 190 | "*Find Lisp Dired Subdirectories*")) |
| 189 | 191 | ||
| 190 | ;; Most of this is lifted from find-dired.el | 192 | ;; Most of this is lifted from find-dired.el |
| 191 | ;; | 193 | ;; |
| 192 | (defun find-lisp-find-dired-internal (dir file-predicate | 194 | (defun find-lisp-find-dired-internal (dir file-predicate |
| 193 | directory-predicate buffer-name) | 195 | directory-predicate buffer-name) |
| 194 | "Run find (Lisp version) and go into Dired mode on a buffer of the output." | 196 | "Run find (Lisp version) and go into Dired mode on a buffer of the output." |
| 195 | (let ((dired-buffers dired-buffers) | 197 | (let ((dired-buffers dired-buffers) |
| @@ -202,7 +204,7 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 202 | ;; Check that it's really a directory. | 204 | ;; Check that it's really a directory. |
| 203 | (or (file-directory-p dir) | 205 | (or (file-directory-p dir) |
| 204 | (error "find-dired needs a directory: %s" dir)) | 206 | (error "find-dired needs a directory: %s" dir)) |
| 205 | (or | 207 | (or |
| 206 | (and (buffer-name) | 208 | (and (buffer-name) |
| 207 | (string= buffer-name (buffer-name))) | 209 | (string= buffer-name (buffer-name))) |
| 208 | (switch-to-buffer (setq buf (get-buffer-create buffer-name)))) | 210 | (switch-to-buffer (setq buf (get-buffer-create buffer-name)))) |
| @@ -226,7 +228,7 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 226 | (setq revert-buffer-function | 228 | (setq revert-buffer-function |
| 227 | (function | 229 | (function |
| 228 | (lambda(ignore1 ignore2) | 230 | (lambda(ignore1 ignore2) |
| 229 | (find-lisp-insert-directory | 231 | (find-lisp-insert-directory |
| 230 | default-directory | 232 | default-directory |
| 231 | find-lisp-file-predicate | 233 | find-lisp-file-predicate |
| 232 | find-lisp-directory-predicate | 234 | find-lisp-directory-predicate |
| @@ -240,23 +242,23 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 240 | ;; and later) | 242 | ;; and later) |
| 241 | (dired-simple-subdir-alist) | 243 | (dired-simple-subdir-alist) |
| 242 | ;; else we have an ancient tree dired (or classic dired, where | 244 | ;; else we have an ancient tree dired (or classic dired, where |
| 243 | ;; this does no harm) | 245 | ;; this does no harm) |
| 244 | (set (make-local-variable 'dired-subdir-alist) | 246 | (set (make-local-variable 'dired-subdir-alist) |
| 245 | (list (cons default-directory (point-min-marker))))) | 247 | (list (cons default-directory (point-min-marker))))) |
| 246 | (find-lisp-insert-directory | 248 | (find-lisp-insert-directory |
| 247 | dir file-predicate directory-predicate 'ignore) | 249 | dir file-predicate directory-predicate 'ignore) |
| 248 | (goto-char (point-min)) | 250 | (goto-char (point-min)) |
| 249 | (dired-goto-next-file))) | 251 | (dired-goto-next-file))) |
| 250 | 252 | ||
| 251 | (defun find-lisp-insert-directory (dir | 253 | (defun find-lisp-insert-directory (dir |
| 252 | file-predicate | 254 | file-predicate |
| 253 | directory-predicate | 255 | directory-predicate |
| 254 | sort-function) | 256 | sort-function) |
| 255 | "Insert the results of `find-lisp-find-files' in the current buffer." | 257 | "Insert the results of `find-lisp-find-files' in the current buffer." |
| 256 | (let ((buffer-read-only nil) | 258 | (let ((buffer-read-only nil) |
| 257 | (files (find-lisp-find-files-internal | 259 | (files (find-lisp-find-files-internal |
| 258 | dir | 260 | dir |
| 259 | file-predicate | 261 | file-predicate |
| 260 | directory-predicate)) | 262 | directory-predicate)) |
| 261 | (len (length dir))) | 263 | (len (length dir))) |
| 262 | (erase-buffer) | 264 | (erase-buffer) |
| @@ -264,7 +266,7 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 264 | ;; subdir-alist points there. | 266 | ;; subdir-alist points there. |
| 265 | (insert find-lisp-line-indent dir ":\n") | 267 | (insert find-lisp-line-indent dir ":\n") |
| 266 | ;; Make second line a ``find'' line in analogy to the ``total'' or | 268 | ;; Make second line a ``find'' line in analogy to the ``total'' or |
| 267 | ;; ``wildcard'' line. | 269 | ;; ``wildcard'' line. |
| 268 | ;; | 270 | ;; |
| 269 | ;; No analog for find-lisp? | 271 | ;; No analog for find-lisp? |
| 270 | (insert find-lisp-line-indent "\n") | 272 | (insert find-lisp-line-indent "\n") |
| @@ -272,7 +274,7 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 272 | (mapcar | 274 | (mapcar |
| 273 | (function | 275 | (function |
| 274 | (lambda(file) | 276 | (lambda(file) |
| 275 | (find-lisp-find-dired-insert-file | 277 | (find-lisp-find-dired-insert-file |
| 276 | (substring file len) | 278 | (substring file len) |
| 277 | (current-buffer)))) | 279 | (current-buffer)))) |
| 278 | (sort files 'string-lessp)) | 280 | (sort files 'string-lessp)) |
| @@ -289,7 +291,7 @@ It is a function which takes two arguments, the directory and its parent." | |||
| 289 | 291 | ||
| 290 | (defun find-lisp-find-dired-insert-file (file buffer) | 292 | (defun find-lisp-find-dired-insert-file (file buffer) |
| 291 | (set-buffer buffer) | 293 | (set-buffer buffer) |
| 292 | (insert find-lisp-line-indent | 294 | (insert find-lisp-line-indent |
| 293 | (find-lisp-format file (file-attributes file) (list "") | 295 | (find-lisp-format file (file-attributes file) (list "") |
| 294 | (current-time)))) | 296 | (current-time)))) |
| 295 | 297 | ||