changeset 8908:25d8b804abd3

(file-name-sans-extension): New function.
author Richard M. Stallman <rms@gnu.org>
date Mon, 19 Sep 1994 04:32:41 +0000
parents f7de8b4cb1b8
children d9c10eb46ce9
files lisp/files.el
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Mon Sep 19 00:18:27 1994 +0000
+++ b/lisp/files.el	Mon Sep 19 04:32:41 1994 +0000
@@ -1429,6 +1429,19 @@
 			 (string-match "~\\'" name)
 			 (length name))))))))
 
+(defun file-name-sans-extension (filename)
+  "Return FILENAME sans final \"extension\".
+The extension, in a file name, is the part that follows the last `.'."
+  (save-match-data
+    (let ((file (file-name-sans-versions (file-name-nondirectory filename)))
+	  directory)
+      (if (string-match "\\.[^.]*\\'" file)
+	  (if (setq directory (file-name-directory filename))
+	      (expand-file-name (substring file 0 (match-beginning 0))
+				directory)
+	    (substring file 0 (match-beginning 0)))
+	filename))))
+
 (defun make-backup-file-name (file)
   "Create the non-numeric backup file name for FILE.
 This is a separate function so you can redefine it for customization."