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

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

Re: Something like `with-eval-before-load'?


From: Yuri Khan
Subject: Re: Something like `with-eval-before-load'?
Date: Wed, 26 Nov 2014 09:17:42 +0700

On Tue, Nov 25, 2014 at 10:35 PM, Alexander Shukaev <haroogan@gmail.com> wrote:
> `with-eval-after-load' is indeed very handy form. But currently I'm in the
> situation where I need its counterpart --- `with-eval-before-load'.

“with-eval-after-load” is possible because time flows forward.

At the time (with-eval-after-load MODULE FORM) is evaluated, there are
two possibilities: either MODULE has already been loaded, or not. If
it has, the FORM is evaluated immediately. If not, a hook is created
that will be called when and if MODULE is eventually loaded.

Now imagine your hypothetical “with-eval-before-load” form.

(with-eval-before-load MODULE FORM)

If MODULE has not yet been loaded, easy. Create a hook; when a request
to load MODULE is made, call the hook before loading it.

But if MODULE has already been loaded, we’re out of luck. Try as we
might, we cannot execute FORM *before* loading MODULE — it would
require us to go back in time.

Either that, or your modular config system has to resolve dependencies
so that the module which evaluates (with-eval-before-load MODULE) is
always loaded before MODULE. But that’s precisely what you’re trying
to solve with “with-eval-before-load” — the problem reduces to itself.

You can achieve what you want by introducing a convention: *first*
load all your init-* modules and arrange them so that they do not
(require) anything; and only *then* selectively (require) anything you
want.



reply via email to

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