Having a relative path, how do I turn it into an absolute one from the location where the elisp file that I'm loading is. That is, I have an elisp file that I'm loading, it has an relative path and I need an absolute one.
You can use the expand-file-name
function to convert a relative filename or path into an absolute filename/path. Look here for additional information.
I ended up using:
(expand-file-name "relative/path" (file-name-directory load-file-name))
'file-truename
From the documentation:
Return the truename of FILENAME, which should be absolute. The truename of a file name is found by chasing symbolic links both at the level of the file and at the level of the directories containing it, until no links are left at any level.
The other solution proffered ('expand-file-name) leaves symbolic links in place, which may or may not be what you want. 'file-truename uses 'expand-file-name, so they both will determine the path relative default-directory for the buffer (which is what you're asking for).
After seeing the comment/question to a different answer, the problem is that the default-directory is that of the buffer that is calling 'load.
Luckily, there's a variable that 'load sets that stores the path to the file being loaded. Try this snippet of code out:
;; this is in the file being loaded
(let ((default-directory (file-name-directory load-file-name)))
(file-truename "blih"))