Implement a new function directory-files-recursively
* doc/lispref/files.texi (Contents of Directories): Document directory-files-recursively. * etc/NEWS: Mention directory-files-recursively. * lisp/files.el (find-files): New function.
This commit is contained in:
parent
931f6fb6f5
commit
11cf3e90c6
6 changed files with 43 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
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.
|
||||
|
|
3
etc/NEWS
3
etc/NEWS
|
@ -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
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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.
|
||||
|
||||
|
|
|
@ -762,6 +762,27 @@ prevented. Directory entries are sorted with string-lessp."
|
|||
(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.
|
||||
|
|
Loading…
Add table
Reference in a new issue