aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/files.el
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>1992-09-27 02:40:49 +0000
committerRoland McGrath <[email protected]>1992-09-27 02:40:49 +0000
commit71fe1fcc5672aaf6deb139d54692717b34670053 (patch)
tree929138a3451e430241388734840c25f0135a1755 /lisp/files.el
parentea912aa6945ae9fb0c2075fca46e39975f8cfaad (diff)
(file-relative-name): Rewritten so unrelativizable file names win.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 0a0052a01a..db50e86dcc 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.