mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-25 10:47:00 +00:00
(file-relative-name): Don't lose when DIRECTORY is nil.
This commit is contained in:
parent
6c636af99b
commit
ea912aa694
@ -940,7 +940,8 @@ Value is a list whose car is the name for the backup file
|
|||||||
(defun file-relative-name (filename &optional directory)
|
(defun file-relative-name (filename &optional directory)
|
||||||
"Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
|
"Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
|
||||||
(setq filename (expand-file-name filename)
|
(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)
|
||||||
default-directory)))
|
default-directory)))
|
||||||
(while (not (string-match (concat "^" (regexp-quote directory)) filename))
|
(while (not (string-match (concat "^" (regexp-quote directory)) filename))
|
||||||
(setq directory (file-name-directory (substring directory 0 -1))))
|
(setq directory (file-name-directory (substring directory 0 -1))))
|
||||||
|
Loading…
Reference in New Issue
Block a user