[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Suggestion about a minor change of `file-name-extension' for bac
From: |
Kazuo YAGI |
Subject: |
[PATCH] Suggestion about a minor change of `file-name-extension' for backup filenames |
Date: |
Tue, 17 Mar 2009 19:07:55 +0900 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080227) |
;In GNU Emacs 23.0.91.1 (i686-pc-linux-gnu, GTK+ Version 2.12.9)
Hi everyone,
I'd like to suggest changing a function's `file-name-extension' behavior.
First of all, would you try to evaluate 2 patterns emacs-lisps below?
a. (file-name-extension "abc.el")
b. (file-name-extension "abc.el~")
Though I know Emacs take a special care of the backup filenames, I have a
strange feeling that b pattern returns "el". I find out this is because
the function `file-name-extension' called internally another low level function
`file-name-sans-versions' with no optional argument in `files.el'
That is why I'd like to suggest changing this function. I think this function
will
become more flexible after applying the attached patch. We can use it as
follows.
b. (file-name-extension "abc.el~" "." t)
I would like to hear from you about this patch.
Thanks,
- Kazuo YAGI
--- files.el.orig 2009-03-03 10:58:07.000000000 +0900
+++ files.el 2009-03-17 18:19:19.000000000 +0900
@@ -3682,7 +3682,7 @@ except that a leading `.', if any, doesn
(substring file 0 (match-beginning 0)))
filename))))
-(defun file-name-extension (filename &optional period)
+(defun file-name-extension (filename &optional period backup-version)
"Return FILENAME's final \"extension\".
The extension, in a file name, is the part that follows the last `.',
excluding version numbers and backup suffixes,
@@ -3694,7 +3694,7 @@ If PERIOD is non-nil, then the returned
that delimits the extension, and if FILENAME has no extension,
the value is \"\"."
(save-match-data
- (let ((file (file-name-sans-versions (file-name-nondirectory filename))))
+ (let ((file (file-name-sans-versions (file-name-nondirectory filename) (if
backup-version t nil))))
(if (and (string-match "\\.[^.]*\\'" file)
(not (eq 0 (match-beginning 0))))
(substring file (+ (match-beginning 0) (if period 0 1)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Suggestion about a minor change of `file-name-extension' for backup filenames,
Kazuo YAGI <=