Clarify doc string of 'file-name-sans-extension'

* lisp/files.el (file-name-sans-extension, file-name-extension):
Clarify in the doc strings what is the extension, and which
leading period doesn't count.  (Bug#23643)
This commit is contained in:
Eli Zaretskii 2016-05-29 17:59:59 +03:00
parent bffda223c2
commit 5e184861c3

View file

@ -4257,8 +4257,8 @@ the group would be preserved too."
(defun file-name-sans-extension (filename) (defun file-name-sans-extension (filename)
"Return FILENAME sans final \"extension\". "Return FILENAME sans final \"extension\".
The extension, in a file name, is the part that follows the last `.', The extension, in a file name, is the part that begins with the last `.',
except that a leading `.', if any, doesn't count." except that a leading `.' of the file name, if there is one, doesn't count."
(save-match-data (save-match-data
(let ((file (file-name-sans-versions (file-name-nondirectory filename))) (let ((file (file-name-sans-versions (file-name-nondirectory filename)))
directory) directory)
@ -4273,15 +4273,16 @@ except that a leading `.', if any, doesn't count."
(defun file-name-extension (filename &optional period) (defun file-name-extension (filename &optional period)
"Return FILENAME's final \"extension\". "Return FILENAME's final \"extension\".
The extension, in a file name, is the part that follows the last `.', The extension, in a file name, is the part that begins with the last `.',
excluding version numbers and backup suffixes, excluding version numbers and backup suffixes, except that a leading `.'
except that a leading `.', if any, doesn't count. of the file name, if there is one, doesn't count.
Return nil for extensionless file names such as `foo'. Return nil for extensionless file names such as `foo'.
Return the empty string for file names such as `foo.'. Return the empty string for file names such as `foo.'.
If PERIOD is non-nil, then the returned value includes the period By default, the returned value excludes the period that starts the
that delimits the extension, and if FILENAME has no extension, extension, but if the optional argument PERIOD is non-nil, the period
the value is \"\"." is included in the value, and in that case, if FILENAME has no
extension, the value is \"\"."
(save-match-data (save-match-data
(let ((file (file-name-sans-versions (file-name-nondirectory filename)))) (let ((file (file-name-sans-versions (file-name-nondirectory filename))))
(if (and (string-match "\\.[^.]*\\'" file) (if (and (string-match "\\.[^.]*\\'" file)