aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-12-03 16:59:42 +0200
committerEli Zaretskii2015-12-03 16:59:42 +0200
commiteca277f937f4c51b83fa0f156b8081e88ea3f121 (patch)
treed762076988dc63596a07161e60924ea9d8e157d8
parent4d10a7d467b6b0927036387c0d4849b2f40abcee (diff)
downloademacs-eca277f937f4c51b83fa0f156b8081e88ea3f121.tar.gz
emacs-eca277f937f4c51b83fa0f156b8081e88ea3f121.zip
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.
-rw-r--r--doc/lispref/files.texi12
-rw-r--r--etc/NEWS12
-rw-r--r--lisp/files.el11
3 files changed, 22 insertions, 13 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index e8ed7ccd9f7..918bf5becbd 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2030,11 +2030,6 @@ form.
2030@end example 2030@end example
2031@end defun 2031@end defun
2032 2032
2033@defun directory-name-p filename
2034This function returns non-@code{nil} if @var{filename} ends with a
2035forward slash (@samp{/}) character.
2036@end defun
2037
2038@node Directory Names 2033@node Directory Names
2039@subsection Directory Names 2034@subsection Directory Names
2040@cindex directory name 2035@cindex directory name
@@ -2076,6 +2071,13 @@ string (if it does not already end in one).
2076@end example 2071@end example
2077@end defun 2072@end defun
2078 2073
2074@defun directory-name-p filename
2075This function returns non-@code{nil} if @var{filename} ends with a
2076directory separator character. This is the forward slash @samp{/} on
2077Unix and GNU systems; MS-Windows and MS-DOS recognize both the forward
2078slash and the backslash @samp{\} as directory separators.
2079@end defun
2080
2079@defun directory-file-name dirname 2081@defun directory-file-name dirname
2080This function returns a string representing @var{dirname} in a form 2082This function returns a string representing @var{dirname} in a form
2081that the operating system will interpret as the name of a file (a 2083that the operating system will interpret as the name of a file (a
diff --git a/etc/NEWS b/etc/NEWS
index bd7435b1760..fa43a7f9f6a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -181,11 +181,6 @@ for use in Emacs bug reports.
181hiding character but the default `.' can be used by let-binding the 181hiding character but the default `.' can be used by let-binding the
182variable `read-hide-char'. 182variable `read-hide-char'.
183 183
184** The new function `directory-name-p' can be used to check whether a file
185name (as returned from, for instance, `file-name-all-completions' is
186a directory file name. It returns non-nil if the last character in
187the name is a forward slash.
188
189** The function `font-info' now returns more details about a font. 184** The function `font-info' now returns more details about a font.
190In particular, it now returns the average width of the font's 185In particular, it now returns the average width of the font's
191characters, which can be used for geometry-related calculations. 186characters, which can be used for geometry-related calculations.
@@ -1302,6 +1297,13 @@ integers.
1302** New function `set-binary-mode' allows to switch a standard stream 1297** New function `set-binary-mode' allows to switch a standard stream
1303of the Emacs process to binary I/O mode. 1298of the Emacs process to binary I/O mode.
1304 1299
1300+++
1301** The new function `directory-name-p' can be used to check whether a file
1302name (as returned from, for instance, `file-name-all-completions') is
1303a directory file name. It returns non-nil if the last character in
1304the name is a directory separator character (forward slash on GNU and
1305Unix systems, forward- or backslash on MS-Windows and MS-DOS).
1306
1305** ASCII approximations to curved quotes are put in standard-display-table 1307** ASCII approximations to curved quotes are put in standard-display-table
1306if the terminal cannot display curved quotes. 1308if the terminal cannot display curved quotes.
1307 1309
diff --git a/lisp/files.el b/lisp/files.el
index f37c23b7bdd..d20bb1401fa 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -740,9 +740,14 @@ The path separator is colon in GNU and GNU-like systems."
740 (error "No such directory found via CDPATH environment variable")))) 740 (error "No such directory found via CDPATH environment variable"))))
741 741
742(defsubst directory-name-p (name) 742(defsubst directory-name-p (name)
743 "Return non-nil if NAME ends with a slash character." 743 "Return non-nil if NAME ends with a directory separator character."
744 (and (> (length name) 0) 744 (let ((len (length name))
745 (char-equal (aref name (1- (length name))) ?/))) 745 (lastc ?.))
746 (if (> len 0)
747 (setq lastc (aref name (1- len))))
748 (or (= lastc ?/)
749 (and (memq system-type '(windows-nt ms-dos))
750 (= lastc ?\\)))))
746 751
747(defun directory-files-recursively (dir regexp &optional include-directories) 752(defun directory-files-recursively (dir regexp &optional include-directories)
748 "Return list of all files under DIR that have file names matching REGEXP. 753 "Return list of all files under DIR that have file names matching REGEXP.