diff options
author | Philipp Stephani <phst@google.com> | 2017-12-30 17:56:27 +0100 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-12-30 21:25:53 +0100 |
commit | 55ae23e4a1e26d0c74568da2d8997196afef7d32 (patch) | |
tree | 7473c3b8984e1f1cf8a6696f0557e632ec8a8652 /f.el | |
parent | c032ec92278b7161bc3467e53876c0bcd9fd7b10 (diff) |
Have f-expand return a directory name if a directory name is given
Various Emacs functions distinguish between directory names and directory file
names, so f.el functions shouldn’t silently convert from one to the other.
Diffstat (limited to 'f.el')
-rw-r--r-- | f.el | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -75,9 +75,13 @@ If PATH is not allowed to be modified, throw error." parts))) (defun f-expand (path &optional dir) - "Expand PATH relative to DIR (or `default-directory')." + "Expand PATH relative to DIR (or `default-directory'). +PATH and DIR can be either a directory names or directory file +names. Return a directory name if PATH is a directory name, and +a directory file name otherwise. File name handlers are +ignored." (let (file-name-handler-alist) - (directory-file-name (expand-file-name path dir)))) + (expand-file-name path dir))) (defun f-filename (path) "Return the name of PATH." @@ -86,7 +90,8 @@ If PATH is not allowed to be modified, throw error." (defalias 'f-parent 'f-dirname) (defun f-dirname (path) "Return the parent directory to PATH." - (let ((parent (file-name-directory (f-expand path default-directory)))) + (let ((parent (file-name-directory + (directory-file-name (f-expand path default-directory))))) (unless (f-same? path parent) (if (f-relative? path) (f-relative parent) @@ -412,8 +417,8 @@ The extension, in a file name, is the part that follows the last (when (and (f-exists? path-a) (f-exists? path-b)) (equal - (f-canonical (f-expand path-a)) - (f-canonical (f-expand path-b))))) + (f-canonical (directory-file-name (f-expand path-a))) + (f-canonical (directory-file-name (f-expand path-b)))))) (defalias 'f-same-p 'f-same?) |