summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1992-09-27 02:40:49 +0000
committerRoland McGrath <roland@gnu.org>1992-09-27 02:40:49 +0000
commite8f0b1049424e62b1ba6cc44d331517427ab49af (patch)
tree5b4787e5e5bd175562a310c9f3dc8c8017fb82e7 /lisp
parent71175aea41879759c3768d014fab231cdb633611 (diff)
downloademacs-e8f0b1049424e62b1ba6cc44d331517427ab49af.tar.gz
(file-relative-name): Rewritten so unrelativizable file names win.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 0a0052a01ae..db50e86dccb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -943,9 +943,17 @@ Value is a list whose car is the name for the backup file
directory (file-name-as-directory (if directory
(expand-file-name directory)
default-directory)))
- (while (not (string-match (concat "^" (regexp-quote directory)) filename))
- (setq directory (file-name-directory (substring directory 0 -1))))
- (substring filename (match-end 0)))
+ (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)))
(defun save-buffer (&optional args)
"Save current buffer in visited file if modified. Versions described below.