help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Refer to the directory of the currently being loaded elisp script fr


From: Óscar Fuentes
Subject: Re: Refer to the directory of the currently being loaded elisp script from within the Emacs lisp file itself.
Date: Fri, 11 Jun 2021 15:49:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> It really does the trick. Thank you for pointing this out. BTW, It should be:
>
>  (setq my-directory (file-name-directory load-file-name))
>
> What about the following according to the tutorial at
> <http://ergoemacs.org/emacs/elisp_relative_path.html>?:
>
> (setq my-directory (file-name-directory (or load-file-name buffer-file-name)))

In general, that's incorrect. See the docsstring of buffer-file-name,
where it is explained that the value of that variable depends on the
current buffer, it is not related at all to the file that contains the
Lisp code being executed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]