When I edit a file, say current-file-path.el
I can have the following code:
(message (format "Here is the path of the current file %s" (buffer-file-name)))
when execting the statement in the buffer of the file when the file is open in a buffer, I got the correct message of the path of the file:
Here is the path of the current file /home/yubrshen/tmp/current-file-path.el
However, if I just load the file, then the message becomes:
Here is the path of the current file nil
What would be the proper way to find out the path of the file where my code is? Actually, I'm interested in knowing the directory of the file of my program so that I can load the other files at the same directory through the program.