aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1992-09-27 02:25:31 +0000
committerRoland McGrath1992-09-27 02:25:31 +0000
commit6c636af99b672bba196a6fd2d08c950485d18845 (patch)
tree6b1a6cbdcec8b6031c2b6655328683df5112c54c
parent1d30b62aa7d30ebfd9fd5cf3101f153b9852ce4a (diff)
downloademacs-6c636af99b672bba196a6fd2d08c950485d18845.tar.gz
emacs-6c636af99b672bba196a6fd2d08c950485d18845.zip
(file-relative-name): New function.
-rw-r--r--lisp/files.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el
index c98ea0ce7a0..0e14d0027f2 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -936,6 +936,15 @@ Value is a list whose car is the name for the backup file
936(defun file-nlinks (filename) 936(defun file-nlinks (filename)
937 "Return number of names file FILENAME has." 937 "Return number of names file FILENAME has."
938 (car (cdr (file-attributes filename)))) 938 (car (cdr (file-attributes filename))))
939
940(defun file-relative-name (filename &optional directory)
941 "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
942 (setq filename (expand-file-name filename)
943 directory (file-name-as-directory (or (expand-file-name directory)
944 default-directory)))
945 (while (not (string-match (concat "^" (regexp-quote directory)) filename))
946 (setq directory (file-name-directory (substring directory 0 -1))))
947 (substring filename (match-end 0)))
939 948
940(defun save-buffer (&optional args) 949(defun save-buffer (&optional args)
941 "Save current buffer in visited file if modified. Versions described below. 950 "Save current buffer in visited file if modified. Versions described below.