Commit eca277f9 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Fix documentation and implementation of 'directory-name-p'

* lisp/files.el (directory-name-p): Modify to recognize
backslashes on MS-Windows and MS-DOS.  Adjust the doc string
accordingly.  Use '=', not char-equal, for comparison, as
letter-case cannot possibly be an issue here.

* doc/lispref/files.texi (Directory Names): Move the documentation
of directory-name-p here from "Relative File Names".  Update the
description per the changes in implementation.

* etc/NEWS: Move the entry for 'directory-name-p' to its proper
place and mark it documented.
parent 4d10a7d4
......@@ -2030,11 +2030,6 @@ 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
......@@ -2076,6 +2071,13 @@ string (if it does not already end in one).
@end example
@end defun
@defun directory-name-p filename
This function returns non-@code{nil} if @var{filename} ends with a
directory separator character. This is the forward slash @samp{/} on
Unix and GNU systems; MS-Windows and MS-DOS recognize both the forward
slash and the backslash @samp{\} as directory separators.
@end defun
@defun directory-file-name dirname
This function returns a string representing @var{dirname} in a form
that the operating system will interpret as the name of a file (a
......
......@@ -181,11 +181,6 @@ for use in Emacs bug reports.
hiding character but the default `.' can be used by let-binding the
variable `read-hide-char'.
** The new function `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.
** The function `font-info' now returns more details about a font.
In particular, it now returns the average width of the font's
characters, which can be used for geometry-related calculations.
......@@ -1302,6 +1297,13 @@ integers.
** New function `set-binary-mode' allows to switch a standard stream
of the Emacs process to binary I/O mode.
+++
** The new function `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 directory separator character (forward slash on GNU and
Unix systems, forward- or backslash on MS-Windows and MS-DOS).
** ASCII approximations to curved quotes are put in standard-display-table
if the terminal cannot display curved quotes.
......
......@@ -740,9 +740,14 @@ The path separator is colon in GNU and GNU-like systems."
(error "No such directory found via CDPATH environment variable"))))
(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))) ?/)))
"Return non-nil if NAME ends with a directory separator character."
(let ((len (length name))
(lastc ?.))
(if (> len 0)
(setq lastc (aref name (1- len))))
(or (= lastc ?/)
(and (memq system-type '(windows-nt ms-dos))
(= lastc ?\\)))))
(defun directory-files-recursively (dir regexp &optional include-directories)
"Return list of all files under DIR that have file names matching REGEXP.
......
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