Commit ea912aa6 authored by Roland McGrath's avatar Roland McGrath
Browse files

(file-relative-name): Don't lose when DIRECTORY is nil.

parent 6c636af9
......@@ -940,7 +940,8 @@ Value is a list whose car is the name for the backup file
(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 (or (expand-file-name directory)
directory (file-name-as-directory (if directory
(expand-file-name directory)
(while (not (string-match (concat "^" (regexp-quote directory)) filename))
(setq directory (file-name-directory (substring directory 0 -1))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment