aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2014-12-13 16:10:04 +0100
committerLars Magne Ingebrigtsen2014-12-13 16:10:04 +0100
commit987d2f9421bc854893673c234c02479583476785 (patch)
tree8f91c1cbcc12063376f2b572bf103e71cc2794df
parent3e8e9713565c3cfacc33763e789514d5960c59e2 (diff)
downloademacs-987d2f9421bc854893673c234c02479583476785.tar.gz
emacs-987d2f9421bc854893673c234c02479583476785.zip
Implement a new function `directory-name-p'
* doc/lispref/files.texi (Relative File Names): Mention `directory-name-p'. * etc/NEWS: Mention directory-name-p. (directory-name-p): New function. (directory-files-recursively): Use it.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/files.texi5
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/files.el7
6 files changed, 26 insertions, 1 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 8f06881adc4..0d8458fabd1 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12014-12-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * files.texi (Relative File Names): Mention `directory-name-p'.
4
12014-12-13 Eli Zaretskii <eliz@gnu.org> 52014-12-13 Eli Zaretskii <eliz@gnu.org>
2 6
3 * text.texi (Comparing Text): Prevent a text string from being 7 * text.texi (Comparing Text): Prevent a text string from being
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 92bb718e46a..b79d5df67c8 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2020,6 +2020,11 @@ form.
2020@end example 2020@end example
2021@end defun 2021@end defun
2022 2022
2023@defun directory-name-p filename
2024This function returns non-@code{nil} if @var{filename} ends with a
2025forward slash (@samp{/}) character.
2026@end defun
2027
2023@node Directory Names 2028@node Directory Names
2024@subsection Directory Names 2029@subsection Directory Names
2025@cindex directory name 2030@cindex directory name
diff --git a/etc/ChangeLog b/etc/ChangeLog
index f56fb4ea683..5e02fced672 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12014-12-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * NEWS: Mention directory-name-p.
4
12014-12-09 Lars Magne Ingebrigtsen <larsi@gnus.org> 52014-12-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 6
3 * NEWS: Mention directory-files-recursively. 7 * NEWS: Mention directory-files-recursively.
diff --git a/etc/NEWS b/etc/NEWS
index 58a5836a1c0..58e4b0e2cf1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -140,6 +140,11 @@ library function `ftw'.
140** A new function `directory-files-recursively' returns all matching 140** A new function `directory-files-recursively' returns all matching
141files (recursively) under a directory. 141files (recursively) under a directory.
142 142
143** The new `directory-name-p' can be used to check whether a file
144name (as returned from, for instance, `file-name-all-completions' is
145a directory file name. It returns non-nil if the last character in
146the name is a forward slash.
147
143 148
144* Editing Changes in Emacs 25.1 149* Editing Changes in Emacs 25.1
145 150
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bc757189f60..6955c3c6cca 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,6 +2,8 @@
2 2
3 * files.el (directory-files-recursively): Really check whether 3 * files.el (directory-files-recursively): Really check whether
4 files are symlinks. 4 files are symlinks.
5 (directory-name-p): New function.
6 (directory-files-recursively): Use it.
5 7
62014-12-13 Artur Malabarba <bruce.connor.am@gmail.com> 82014-12-13 Artur Malabarba <bruce.connor.am@gmail.com>
7 9
diff --git a/lisp/files.el b/lisp/files.el
index 2ab740d4a7f..d55ef1ad538 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -761,6 +761,11 @@ prevented. Directory entries are sorted with string-lessp."
761 (file-name-nondirectory dir) 761 (file-name-nondirectory dir)
762 args)))) 762 args))))
763 763
764(defsubst directory-name-p (name)
765 "Return non-nil if NAME ends with a slash character."
766 (and (> (length name) 0)
767 (char-equal (aref name (1- (length name))) ?/)))
768
764(defun directory-files-recursively (dir match &optional include-directories) 769(defun directory-files-recursively (dir match &optional include-directories)
765 "Return all files under DIR that have file names matching MATCH (a regexp). 770 "Return all files under DIR that have file names matching MATCH (a regexp).
766This function works recursively. Files are returned in \"depth first\" 771This function works recursively. Files are returned in \"depth first\"
@@ -771,7 +776,7 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
771 (dolist (file (sort (file-name-all-completions "" dir) 776 (dolist (file (sort (file-name-all-completions "" dir)
772 'string<)) 777 'string<))
773 (unless (member file '("./" "../")) 778 (unless (member file '("./" "../"))
774 (if (= (aref file (1- (length file))) ?/) 779 (if (directory-name-p file)
775 (let* ((leaf (substring file 0 (1- (length file)))) 780 (let* ((leaf (substring file 0 (1- (length file))))
776 (path (expand-file-name leaf dir))) 781 (path (expand-file-name leaf dir)))
777 ;; Don't follow symlinks to other directories. 782 ;; Don't follow symlinks to other directories.