]> code.delx.au - gnu-emacs/blobdiff - lisp/find-lisp.el
New icons for debugger.
[gnu-emacs] / lisp / find-lisp.el
index e865d29ca6702da7da870936bc9f1028e6f3dabf..937a82348f3d74df271eaa6f6f4fd4c9b6b9aa0e 100644 (file)
@@ -1,9 +1,9 @@
-;;; find-lisp.el --- Emulation of find in Emacs Lisp
+;;; find-lisp.el --- emulation of find in Emacs Lisp
 
-;; Author:  Peter Breton
+;; Author: Peter Breton
 ;; Created: Fri Mar 26 1999
 ;; Keywords: unix
-;; Time-stamp: <2000-10-04 00:17:29 pbreton>
+;; Time-stamp: <2001-07-16 12:42:35 pavel>
 
 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
 
@@ -119,8 +119,7 @@ Argument DIR is the directory containing FILE."
   "Find files in DIRECTORY which match REGEXP."
   (let ((file-predicate      'find-lisp-default-file-predicate)
        (directory-predicate 'find-lisp-default-directory-predicate)
-       (find-lisp-regexp regexp)
-       )
+       (find-lisp-regexp regexp))
     (find-lisp-find-files-internal
      directory
      file-predicate
@@ -135,40 +134,35 @@ directory.
 
 DIRECTORY-PREDICATE is used to decide whether to descend into directories.
 It is a function which takes two arguments, the directory and its parent."
-  (or (string-match "/$" directory)
-      (setq directory (concat directory "/")))
+  (setq directory (file-name-as-directory directory))
   (let (results sub-results)
-    (mapcar
-     (function
-      (lambda(file)
-       (let ((fullname (expand-file-name file directory)))
-         (and (file-readable-p (expand-file-name file directory))
+    (dolist (file (directory-files directory nil nil t))
+      (let ((fullname (expand-file-name file directory)))
+       (when (file-readable-p (expand-file-name file directory))
+         ;; If a directory, check it we should descend into it
+         (and (file-directory-p fullname)
+              (funcall directory-predicate file directory)
               (progn
-                ;; If a directory, check it we should descend into it
-                (and (file-directory-p fullname)
-                     (funcall directory-predicate file directory)
-                     (progn
-                       (setq sub-results
-                             (find-lisp-find-files-internal
-                              fullname
-                              file-predicate
-                              directory-predicate))
-                       (if results
-                           (nconc results sub-results)
-                         (setq results sub-results))))
-                ;; For all files and directories, call the file predicate
-                (and (funcall file-predicate file directory)
-                     (if results
-                         (nconc results (list fullname))
-                       (setq results (list fullname))))
-                )))))
-     (directory-files directory nil nil t))
+                (setq sub-results
+                      (find-lisp-find-files-internal
+                       fullname
+                       file-predicate
+                       directory-predicate))
+                (if results
+                    (nconc results sub-results)
+                  (setq results sub-results))))
+         ;; For all files and directories, call the file predicate
+         (and (funcall file-predicate file directory)
+              (if results
+                  (nconc results (list fullname))
+                (setq results (list fullname)))))))
     results))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Find-dired all in Lisp
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+;;;###autoload
 (defun find-lisp-find-dired (dir regexp)
   "Find files in DIR, matching REGEXP."
   (interactive "DFind files in directory: \nsMatching regexp: ")
@@ -180,6 +174,7 @@ It is a function which takes two arguments, the directory and its parent."
      "*Find Lisp Dired*")))
 
 ;; Just the subdirectories
+;;;###autoload
 (defun find-lisp-find-dired-subdirectories (dir)
   "Find all subdirectories of DIR."
   (interactive "DFind subdirectories of directory: ")
@@ -283,6 +278,7 @@ It is a function which takes two arguments, the directory and its parent."
     (goto-char (point-min))
     (dired-goto-next-file)))
 
+;;;###autoload
 (defun find-lisp-find-dired-filter (regexp)
   "Change the filter on a find-lisp-find-dired buffer to REGEXP."
   (interactive "sSet filter to regexp: ")
@@ -360,8 +356,8 @@ It is a function which takes two arguments, the directory and its parent."
 
 (provide 'find-lisp)
 
-;;; find-lisp.el ends here
-
 ;; Local Variables:
 ;; autocompile: t
 ;; End:
+
+;;; find-lisp.el ends here