aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 2decbe51530..19ae4625625 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2238,11 +2238,13 @@ we do not remove backup version numbers, only true file version numbers."
2238 2238
2239(defun file-name-sans-extension (filename) 2239(defun file-name-sans-extension (filename)
2240 "Return FILENAME sans final \"extension\". 2240 "Return FILENAME sans final \"extension\".
2241The extension, in a file name, is the part that follows the last `.'." 2241The extension, in a file name, is the part that follows the last `.',
2242except that a leading `.', if any, doesn't count."
2242 (save-match-data 2243 (save-match-data
2243 (let ((file (file-name-sans-versions (file-name-nondirectory filename))) 2244 (let ((file (file-name-sans-versions (file-name-nondirectory filename)))
2244 directory) 2245 directory)
2245 (if (string-match "\\.[^.]*\\'" file) 2246 (if (and (string-match "\\.[^.]*\\'" file)
2247 (not (eq 0 (match-beginning 0))))
2246 (if (setq directory (file-name-directory filename)) 2248 (if (setq directory (file-name-directory filename))
2247 (expand-file-name (substring file 0 (match-beginning 0)) 2249 (expand-file-name (substring file 0 (match-beginning 0))
2248 directory) 2250 directory)
@@ -2251,7 +2253,8 @@ The extension, in a file name, is the part that follows the last `.'."
2251 2253
2252(defun file-name-extension (filename &optional period) 2254(defun file-name-extension (filename &optional period)
2253 "Return FILENAME's final \"extension\". 2255 "Return FILENAME's final \"extension\".
2254The extension, in a file name, is the part that follows the last `.'. 2256The extension, in a file name, is the part that follows the last `.',
2257except that a leading `.', if any, doesn't count.
2255Return nil for extensionless file names such as `foo'. 2258Return nil for extensionless file names such as `foo'.
2256Return the empty string for file names such as `foo.'. 2259Return the empty string for file names such as `foo.'.
2257 2260
@@ -2260,7 +2263,8 @@ that delimits the extension, and if FILENAME has no extension,
2260the value is \"\"." 2263the value is \"\"."
2261 (save-match-data 2264 (save-match-data
2262 (let ((file (file-name-sans-versions (file-name-nondirectory filename)))) 2265 (let ((file (file-name-sans-versions (file-name-nondirectory filename))))
2263 (if (string-match "\\.[^.]*\\'" file) 2266 (if (and (string-match "\\.[^.]*\\'" file)
2267 (not (eq 0 (match-beginning 0))))
2264 (substring file (+ (match-beginning 0) (if period 0 1))) 2268 (substring file (+ (match-beginning 0) (if period 0 1)))
2265 (if period 2269 (if period
2266 ""))))) 2270 "")))))