[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 11cf3e9: Implement a new function directory-files-r
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively |
Date: |
Tue, 09 Dec 2014 06:21:21 +0000 |
branch: master
commit 11cf3e90c62e197c600a32f9c226294255abd7a5
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
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.
---
doc/lispref/ChangeLog | 5 +++++
doc/lispref/files.texi | 8 ++++++++
etc/ChangeLog | 4 ++++
etc/NEWS | 3 +++
lisp/ChangeLog | 2 ++
lisp/files.el | 21 +++++++++++++++++++++
6 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index d8215be..e7b5606 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-09 Lars Magne Ingebrigtsen <address@hidden>
+
+ * files.texi (Contents of Directories): Document
+ directory-files-recursively.
+
2014-12-04 Eli Zaretskii <address@hidden>
* display.texi (Bidirectional Display): Document
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index ac77b94..92bb718 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2605,6 +2605,14 @@ An error is signaled if @var{directory} is not the name
of a directory
that can be read.
@end defun
address@hidden directory-files-recursively directory match &optional
include-directories
+Return all files under @var{directory} whose file names match
address@hidden 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 address@hidden,
+also return directory names that have matching names.
address@hidden 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
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 309c01f..9ac0d00 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2014-12-09 Lars Magne Ingebrigtsen <address@hidden>
+
+ * NEWS: Mention directory-files-recursively.
+
2014-12-08 Lars Magne Ingebrigtsen <address@hidden>
* NEWS: Mention the new eww `S' command.
diff --git a/etc/NEWS b/etc/NEWS
index 4bca9e9..58a5836 100644
--- a/etc/NEWS
+++ b/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
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cadb209..9c044c3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
2014-12-09 Lars Magne Ingebrigtsen <address@hidden>
+ * 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.
diff --git a/lisp/files.el b/lisp/files.el
index 0f54a22..5127519 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively,
Lars Ingebrigtsen <=