all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Alexander Shukaev <haroogan@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Something like `with-eval-before-load'?
Date: Wed, 26 Nov 2014 09:17:42 +0700	[thread overview]
Message-ID: <CAP_d_8W436_YpJ4szU6CrX=qG4-TS_xh=exSp8_o6+qWi9zyrA@mail.gmail.com> (raw)
In-Reply-To: <CAKu-7WzF8GJAVBZfRKss-QXPyCRCwWgPD7kiXot_37Mh-oxv-Q@mail.gmail.com>

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	other threads:[~2014-11-26  2:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 16:35 Something like `with-eval-before-load'? Alexander Shukaev
2014-11-26  2:17 ` Yuri Khan [this message]
2014-11-26  9:36   ` Alexander Shukaev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8W436_YpJ4szU6CrX=qG4-TS_xh=exSp8_o6+qWi9zyrA@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=haroogan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.