diff options
| author | Eli Zaretskii | 2015-12-03 16:59:42 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-12-03 16:59:42 +0200 |
| commit | eca277f937f4c51b83fa0f156b8081e88ea3f121 (patch) | |
| tree | d762076988dc63596a07161e60924ea9d8e157d8 | |
| parent | 4d10a7d467b6b0927036387c0d4849b2f40abcee (diff) | |
| download | emacs-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.texi | 12 | ||||
| -rw-r--r-- | etc/NEWS | 12 | ||||
| -rw-r--r-- | lisp/files.el | 11 |
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 | ||
| 2034 | This function returns non-@code{nil} if @var{filename} ends with a | ||
| 2035 | forward 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 | ||
| 2075 | This function returns non-@code{nil} if @var{filename} ends with a | ||
| 2076 | directory separator character. This is the forward slash @samp{/} on | ||
| 2077 | Unix and GNU systems; MS-Windows and MS-DOS recognize both the forward | ||
| 2078 | slash and the backslash @samp{\} as directory separators. | ||
| 2079 | @end defun | ||
| 2080 | |||
| 2079 | @defun directory-file-name dirname | 2081 | @defun directory-file-name dirname |
| 2080 | This function returns a string representing @var{dirname} in a form | 2082 | This function returns a string representing @var{dirname} in a form |
| 2081 | that the operating system will interpret as the name of a file (a | 2083 | that the operating system will interpret as the name of a file (a |
| @@ -181,11 +181,6 @@ for use in Emacs bug reports. | |||
| 181 | hiding character but the default `.' can be used by let-binding the | 181 | hiding character but the default `.' can be used by let-binding the |
| 182 | variable `read-hide-char'. | 182 | variable `read-hide-char'. |
| 183 | 183 | ||
| 184 | ** The new function `directory-name-p' can be used to check whether a file | ||
| 185 | name (as returned from, for instance, `file-name-all-completions' is | ||
| 186 | a directory file name. It returns non-nil if the last character in | ||
| 187 | the 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. |
| 190 | In particular, it now returns the average width of the font's | 185 | In particular, it now returns the average width of the font's |
| 191 | characters, which can be used for geometry-related calculations. | 186 | characters, 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 |
| 1303 | of the Emacs process to binary I/O mode. | 1298 | of 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 | ||
| 1302 | name (as returned from, for instance, `file-name-all-completions') is | ||
| 1303 | a directory file name. It returns non-nil if the last character in | ||
| 1304 | the name is a directory separator character (forward slash on GNU and | ||
| 1305 | Unix 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 |
| 1306 | if the terminal cannot display curved quotes. | 1308 | if 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. |