changeset 1246:5e25dd40a160

(file-relative-name-1): New function split out. (file-relative-name): Use it.
author Richard M. Stallman <rms@gnu.org>
date Mon, 28 Sep 1992 13:02:52 +0000
parents f8a5da3d18e8
children 8dce1588f37f
files lisp/files.el
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Mon Sep 28 13:02:35 1992 +0000
+++ b/lisp/files.el	Mon Sep 28 13:02:52 1992 +0000
@@ -937,23 +937,23 @@
   "Return number of names file FILENAME has."
   (car (cdr (file-attributes filename))))
 
+(defun file-relative-name-1 (directory)
+  (cond ((string= directory "/")
+	 filename)
+	((string-match (concat "^" (regexp-quote directory))
+		       filename)
+	 (substring filename (match-end 0)))
+	(t
+	 (file-relative-name-1
+	  (file-name-directory (substring directory 0 -1))))))
+
 (defun file-relative-name (filename &optional directory)
   "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
   (setq filename (expand-file-name filename)
 	directory (file-name-as-directory (if directory
 					      (expand-file-name directory)
 					      default-directory)))
-  (let ((strip (lambda (directory)
-		 (cond ((string= directory "/")
-			filename)
-		       ((string-match (concat "^" (regexp-quote directory))
-				      filename)
-			(substring filename (match-end 0)))
-		       (t
-			(funcall strip
-				 (file-name-directory (substring directory
-								 0 -1))))))))
-    (funcall strip directory)))
+  (file-relative-name-1 directory))
 
 (defun save-buffer (&optional args)
   "Save current buffer in visited file if modified.  Versions described below.