;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)))
_______________________________________________
gnu-emacs-sources mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to