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

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

Re: How to get the directory of a package?


From: Marcin Borkowski
Subject: Re: How to get the directory of a package?
Date: Wed, 03 Feb 2021 05:55:05 +0100
User-agent: mu4e 1.1.0; emacs 28.0.50

OK,

> assume that I'm writing a package which wants to use a file from the
> same directory the .el (or .elc) file of the package is located in.  How
> can the package know where in the filesystem it is located?
>
> Bonus points for a method which works not only with `require', but also
> with `load-file' and `eval-buffer' (in the last case,
> `default-directory' will probably work, but I skimmed through all
> variables and functions matching `directory$' and nothing seemed to be
> what I'm looking for).

so I think I've found the answer.  Is this correct?  Are there possibly
some edge cases I didn't think about?

--8<---------------cut here---------------start------------->8---
(if load-file-name
    (file-name-directory load-file-name)
  default-directory)
--8<---------------cut here---------------end--------------->8---

TIA,

--
Marcin Borkowski
http://mbork.pl



reply via email to

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