Skip to content

Instantly share code, notes, and snippets.

@nxtr
Created September 3, 2018 18:28
Show Gist options
  • Save nxtr/9926d06b01b7e1b94df46fe414847c29 to your computer and use it in GitHub Desktop.
Save nxtr/9926d06b01b7e1b94df46fe414847c29 to your computer and use it in GitHub Desktop.
Convert filename NAME to absolute and canonicalize, starting with directory of `load-file-name' or `buffer-file-name' or `default-directory' if NAME is relative (does not start with slash or tilde).
(defun expand-file-name-current-directory (name)
"Convert filename NAME to absolute and canonicalize, starting with directory
of `load-file-name' or `buffer-file-name' or `default-directory' if NAME
is relative (does not start with slash or tilde)."
(let ((dir (file-name-directory (or load-file-name buffer-file-name ""))))
(expand-file-name name dir)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment