10

At the top of my elisp module, I want to do something as simple as:

(message (concat "Loading " (expand-file-name (current-elisp-module) ".")))
Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • possible duplicate of [How to refer to the file currently being loaded in Emacs Lisp?](http://stackoverflow.com/questions/1344747/how-to-refer-to-the-file-currently-being-loaded-in-emacs-lisp) – mlt Jul 27 '14 at 03:51

1 Answers1

9

You can use the variable load-file-name, which is set by the function load, documented as follows:

Full name of file being loaded by `load'.

As elaborated in the manual:

When Emacs is in the process of loading a file, this variable’s value is the name of that file, as Emacs found it during the search described earlier in this section.

Note: buffer-file-name as a routine does not work as you might expect it to.

seh
  • 14,999
  • 2
  • 48
  • 58
  • Thanks for rounding out the answer, Trey. I was more hurried than usual writing that, and figured it would be helpful to put it out sooner than later. – seh Dec 29 '09 at 00:57