+2014-12-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * files.texi (Contents of Directories): Document
+ directory-files-recursively.
+
2014-12-04 Eli Zaretskii <eliz@gnu.org>
* display.texi (Bidirectional Display): Document
that can be read.
@end defun
+@defun directory-files-recursively directory match &optional include-directories
+Return all files under @var{directory} whose file names match
+@var{match} recursively. The file names are returned ``depth first'',
+meaning that contents of sub-directories are returned before contents
+of the directories. If @var{include-directories} is non-@code{nil},
+also return directory names that have matching names.
+@end defun
+
@defun directory-files-and-attributes directory &optional full-name match-regexp nosort id-format
This is similar to @code{directory-files} in deciding which files
to report on and how to report their names. However, instead
+2014-12-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * NEWS: Mention directory-files-recursively.
+
2014-12-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
* NEWS: Mention the new eww `S' command.
to all the files and subdirectories of a directory, similarly to the C
library function `ftw'.
+** A new function `directory-files-recursively' returns all matching
+files (recursively) under a directory.
+
\f
* Editing Changes in Emacs 25.1
2014-12-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
+ * files.el (find-files): New function.
+
* net/shr.el (shr-dom-print): Don't print comments.
(shr-tag-svg): Give inline SVG images the right type.
(file-name-nondirectory dir)
args))))
+(defun directory-files-recursively (dir match &optional include-directories)
+ "Return all files under DIR that have file names matching MATCH (a regexp).
+This function works recursively. Files are returned in \"depth first\"
+and alphabetical order.
+If INCLUDE-DIRECTORIES, also include directories that have matching names."
+ (let ((result nil)
+ (files nil))
+ (dolist (file (directory-files dir t))
+ (let ((leaf (file-name-nondirectory file)))
+ (unless (member leaf '("." ".."))
+ (if (file-directory-p file)
+ (progn
+ (when (and include-directories
+ (string-match match leaf))
+ (push file files))
+ (setq result (nconc result (directory-files-recursively
+ file match include-directories))))
+ (when (string-match match leaf)
+ (push file files))))))
+ (nconc result (nreverse files))))
+
(defun load-file (file)
"Load the Lisp file named FILE."
;; This is a case where .elc makes a lot of sense.