[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 3f511afce0 12/27: Add directory-files-recursivel
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 3f511afce0 12/27: Add directory-files-recursively |
Date: |
Sat, 5 Mar 2022 04:57:27 -0500 (EST) |
branch: externals/compat
commit 3f511afce083cc9874e8f769df84ffb616aeff47
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Add directory-files-recursively
---
MANUAL | 2 ++
compat-25.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/MANUAL b/MANUAL
index 6aa23fc97e..c31db87697 100644
--- a/MANUAL
+++ b/MANUAL
@@ -164,6 +164,8 @@ provided by compat by default:
- Macro ~thread-first~ :: Defined in ~subr-x.el~.
- Macro ~thread-last~ :: Defined in ~subr-x.el~.
- Function ~macroexpand-1~ :: See [[info:elisp#Expansion][(elisp) Expansion]].
+- Function ~directory-files-recursively~ :: See [[info:elisp#Contents of
Directories][(elisp) Contents of
+ Directories]].
These functions are prefixed with ~compat~ prefix, and are only loaded
when ~compat-25~ is required:
diff --git a/compat-25.el b/compat-25.el
index 6ec497d9e9..da084b807e 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -265,5 +265,66 @@ So far, FUNCTION can only be a symbol, not a lambda
expression."
:version "24.4"
(put func prop value))
+;;;; Defined in files.el
+
+(compat-defun directory-files-recursively
+ (dir regexp &optional include-directories predicate follow-symlinks)
+ "Return list of all files under directory DIR whose names match REGEXP.
+This function works recursively. Files are returned in \"depth
+first\" order, and files from each directory are sorted in
+alphabetical order. Each file name appears in the returned list
+in its absolute form.
+
+By default, the returned list excludes directories, but if
+optional argument INCLUDE-DIRECTORIES is non-nil, they are
+included.
+
+PREDICATE can be either nil (which means that all subdirectories
+of DIR are descended into), t (which means that subdirectories that
+can't be read are ignored), or a function (which is called with
+the name of each subdirectory, and should return non-nil if the
+subdirectory is to be descended into).
+
+If FOLLOW-SYMLINKS is non-nil, symbolic links that point to
+directories are followed. Note that this can lead to infinite
+recursion."
+ (let* ((result nil)
+ (files nil)
+ (dir (directory-file-name dir))
+ ;; When DIR is "/", remote file names like "/method:" could
+ ;; also be offered. We shall suppress them.
+ (tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir)))))
+ (dolist (file (sort (file-name-all-completions "" dir)
+ 'string<))
+ (unless (member file '("./" "../"))
+ (if (directory-name-p file)
+ (let* ((leaf (substring file 0 (1- (length file))))
+ (full-file (concat dir "/" leaf)))
+ ;; Don't follow symlinks to other directories.
+ (when (and (or (not (file-symlink-p full-file))
+ (and (file-symlink-p full-file)
+ follow-symlinks))
+ ;; Allow filtering subdirectories.
+ (or (eq predicate nil)
+ (eq predicate t)
+ (funcall predicate full-file)))
+ (let ((sub-files
+ (if (eq predicate t)
+ (condition-case nil
+ (directory-files-recursively
+ full-file regexp include-directories
+ predicate follow-symlinks)
+ (file-error nil))
+ (directory-files-recursively
+ full-file regexp include-directories
+ predicate follow-symlinks))))
+ (setq result (nconc result sub-files))))
+ (when (and include-directories
+ (string-match regexp leaf))
+ (setq result (nconc result (list full-file)))))
+ (when (string-match regexp file)
+ (push (concat dir "/" file) files)))))
+ (nconc result (nreverse files))))
+
(provide 'compat-25)
;;; compat-25.el ends here
- [elpa] externals/compat updated (88d26596cb -> 9fa3fbab8a), ELPA Syncer, 2022/03/05
- [elpa] externals/compat e4db344ed5 01/27: Add MANUAL, ELPA Syncer, 2022/03/05
- [elpa] externals/compat f475f8027b 08/27: Set compat--generate-function globally when loading compat-tests, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 511801e28f 02/27: Fix typo in README, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 0706a69997 04/27: Avoid using gensym in with-existing-directory, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 28a6e2db53 06/27: Remove unnecessary whitespace before closing parentheses, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 26ee17853e 07/27: Add bool-vector functions, ELPA Syncer, 2022/03/05
- [elpa] externals/compat efb9ff712a 10/27: Add completion-table-merge and completion-table-with-cache, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 4aca90834f 09/27: Add get-pos-property to missing functions in 24.4, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 3f511afce0 12/27: Add directory-files-recursively,
ELPA Syncer <=
- [elpa] externals/compat efa6e171e5 13/27: Document define-advice as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 441539ae8b 11/27: Add face-spec-set, ELPA Syncer, 2022/03/05
- [elpa] externals/compat b3b75333b1 14/27: Document generators as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat c4893fa014 15/27: Document bufferpos-to-filepos as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 35072b3d25 22/27: Fix if-let and add tests, ELPA Syncer, 2022/03/05
- [elpa] externals/compat ece91a5b89 03/27: Add function-put, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 9034bcc0ac 05/27: Fix broken markup in some deftest docstrings, ELPA Syncer, 2022/03/05
- [elpa] externals/compat c8bc47b671 18/27: Add replace-string-in-region, ELPA Syncer, 2022/03/05
- [elpa] externals/compat a92aec7251 19/27: Add file-modes-number-to-symbolic, ELPA Syncer, 2022/03/05
- [elpa] externals/compat ba2918d6d3 21/27: Add file-backup-file-names, ELPA Syncer, 2022/03/05