[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 558053dcae: compat-28: Add directory-files-and-a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 558053dcae: compat-28: Add directory-files-and-attributes with COUNT argument |
Date: |
Wed, 18 Jan 2023 15:57:25 -0500 (EST) |
branch: externals/compat
commit 558053dcae1763003d15386092167a5078d9960a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
compat-28: Add directory-files-and-attributes with COUNT argument
---
NEWS.org | 1 +
compat-28.el | 10 ++++++++++
compat-tests.el | 7 +++++++
3 files changed, 18 insertions(+)
diff --git a/NEWS.org b/NEWS.org
index d700de1f99..8589332a9f 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -7,6 +7,7 @@
- compat-27: Add ~make-decoded-time~.
- compat-28: Add ~color-dark-p~.
- compat-28: Add ~with-window-non-dedicated~.
+- compat-28: Add ~directory-files-and-attributes~ with COUNT argument.
- compat-29: Add ~compiled-function-p~.
- compat-29: Add ~plist-get~ generalized variable.
- compat-29: Add ~plistp~.
diff --git a/compat-28.el b/compat-28.el
index 6149106e31..953ce2e721 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -135,6 +135,16 @@ If COUNT is non-nil and a natural number, the function will
(setf (nthcdr count files) nil))
files))
+(compat-defun directory-files-and-attributes (directory &optional full match
nosort id-format count) ;; <compat-tests:directory-files-and-attributs>
+ "Handle additional optional argument COUNT.
+If COUNT is non-nil and a natural number, the function will
+ return COUNT number of file names (if so many are present)."
+ :explicit t
+ (let ((files (directory-files-and-attributes directory full match nosort
id-format)))
+ (when (natnump count)
+ (setf (nthcdr count files) nil))
+ files))
+
;;;; xfaces.c
(compat-defun color-values-from-color-spec (spec) ;;
<compat-tests:color-values-from-color-spec>
diff --git a/compat-tests.el b/compat-tests.el
index 9c8f4dd8ce..b9e5a0b2f1 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1384,9 +1384,16 @@
(ert-deftest directory-files ()
(should-not (compat-call directory-files "." nil nil nil 0))
+ (should (list-of-strings-p (compat-call directory-files "." nil nil nil 1)))
(should-equal 1 (length (compat-call directory-files "." nil nil nil 1)))
(should-equal 2 (length (compat-call directory-files "." nil nil nil 2))))
+(ert-deftest directory-files-and-attributes ()
+ (should-not (compat-call directory-files-and-attributes "." nil nil nil nil
0))
+ (should (consp (car (compat-call directory-files-and-attributes "." nil nil
nil nil 1))))
+ (should-equal 1 (length (compat-call directory-files-and-attributes "." nil
nil nil nil 1)))
+ (should-equal 2 (length (compat-call directory-files-and-attributes "." nil
nil nil nil 2))))
+
(ert-deftest directory-name-p ()
(should (directory-name-p "/"))
(should-not (directory-name-p "/file"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/compat 558053dcae: compat-28: Add directory-files-and-attributes with COUNT argument,
ELPA Syncer <=