Skip to content

Instantly share code, notes, and snippets.

@nxtr
Created December 9, 2018 23:51
Show Gist options
  • Save nxtr/644d712fe8ae629068129c2f4b34ab95 to your computer and use it in GitHub Desktop.
Save nxtr/644d712fe8ae629068129c2f4b34ab95 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 startwith slash or tilde).
(eval-and-compile
(unless (fboundp 'expand-file-name-current-directory)
(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 startwith 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