diff options
| author | Eli Zaretskii | 2001-10-22 16:11:12 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2001-10-22 16:11:12 +0000 |
| commit | 2531b0c39cfaa49409c361069407eda2a5f7d2da (patch) | |
| tree | cde38d91aa149038291a77c206020a174cb7168b | |
| parent | 653c329be8a9a4d37a15df4795050989168c7b3f (diff) | |
| download | emacs-2531b0c39cfaa49409c361069407eda2a5f7d2da.tar.gz emacs-2531b0c39cfaa49409c361069407eda2a5f7d2da.zip | |
(file-name-sans-extension, file-name-extension): Don't
count the leading dots in file names as signaling an extension.
| -rw-r--r-- | lisp/files.el | 12 |
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\". |
| 2241 | The extension, in a file name, is the part that follows the last `.'." | 2241 | The extension, in a file name, is the part that follows the last `.', |
| 2242 | except 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\". |
| 2254 | The extension, in a file name, is the part that follows the last `.'. | 2256 | The extension, in a file name, is the part that follows the last `.', |
| 2257 | except that a leading `.', if any, doesn't count. | ||
| 2255 | Return nil for extensionless file names such as `foo'. | 2258 | Return nil for extensionless file names such as `foo'. |
| 2256 | Return the empty string for file names such as `foo.'. | 2259 | Return 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, | |||
| 2260 | the value is \"\"." | 2263 | the 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 | ""))))) |