Commit 987d2f94 authored by Lars Magne Ingebrigtsen's avatar Lars Magne Ingebrigtsen
Browse files

Implement a new function `directory-name-p'

* doc/lispref/files.texi (Relative File Names): Mention

* etc/NEWS: Mention directory-name-p.

(directory-name-p): New function.
(directory-files-recursively): Use it.
parent 3e8e9713
2014-12-13 Lars Magne Ingebrigtsen <>
* files.texi (Relative File Names): Mention `directory-name-p'.
2014-12-13 Eli Zaretskii <>
* text.texi (Comparing Text): Prevent a text string from being
......@@ -2020,6 +2020,11 @@ form.
@end example
@end defun
@defun directory-name-p filename
This function returns non-@code{nil} if @var{filename} ends with a
forward slash (@samp{/}) character.
@end defun
@node Directory Names
@subsection Directory Names
@cindex directory name
2014-12-13 Lars Magne Ingebrigtsen <>
* NEWS: Mention directory-name-p.
2014-12-09 Lars Magne Ingebrigtsen <>
* NEWS: Mention directory-files-recursively.
......@@ -140,6 +140,11 @@ library function `ftw'.
** A new function `directory-files-recursively' returns all matching
files (recursively) under a directory.
** The new `directory-name-p' can be used to check whether a file
name (as returned from, for instance, `file-name-all-completions' is
a directory file name. It returns non-nil if the last character in
the name is a forward slash.
* Editing Changes in Emacs 25.1
......@@ -2,6 +2,8 @@
* files.el (directory-files-recursively): Really check whether
files are symlinks.
(directory-name-p): New function.
(directory-files-recursively): Use it.
2014-12-13 Artur Malabarba <>
......@@ -761,6 +761,11 @@ prevented. Directory entries are sorted with string-lessp."
(file-name-nondirectory dir)
(defsubst directory-name-p (name)
"Return non-nil if NAME ends with a slash character."
(and (> (length name) 0)
(char-equal (aref name (1- (length name))) ?/)))
(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\"
......@@ -771,7 +776,7 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
(dolist (file (sort (file-name-all-completions "" dir)
(unless (member file '("./" "../"))
(if (= (aref file (1- (length file))) ?/)
(if (directory-name-p file)
(let* ((leaf (substring file 0 (1- (length file))))
(path (expand-file-name leaf dir)))
;; Don't follow symlinks to other directories.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment