Commit 11cf3e90 authored by Lars Magne Ingebrigtsen's avatar Lars Magne Ingebrigtsen
Browse files

Implement a new function directory-files-recursively

* doc/lispref/files.texi (Contents of Directories): Document

* etc/NEWS: Mention directory-files-recursively.

* lisp/files.el (find-files): New function.
parent 931f6fb6
2014-12-09 Lars Magne Ingebrigtsen <>
* files.texi (Contents of Directories): Document
2014-12-04 Eli Zaretskii <>
* display.texi (Bidirectional Display): Document
......@@ -2605,6 +2605,14 @@ An error is signaled if @var{directory} is not the name of a directory
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 <>
* NEWS: Mention directory-files-recursively.
2014-12-08 Lars Magne Ingebrigtsen <>
* NEWS: Mention the new eww `S' command.
......@@ -137,6 +137,9 @@ buffers to allow certain parts of the text to be writable.
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.
* Editing Changes in Emacs 25.1
2014-12-09 Lars Magne Ingebrigtsen <>
* 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.
......@@ -762,6 +762,27 @@ prevented. Directory entries are sorted with string-lessp."
(file-name-nondirectory dir)
(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)
(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.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment