From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Something like `with-eval-before-load'? Date: Wed, 26 Nov 2014 09:17:42 +0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1416968283 30603 80.91.229.3 (26 Nov 2014 02:18:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Nov 2014 02:18:03 +0000 (UTC) Cc: help-gnu-emacs To: Alexander Shukaev Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 26 03:17:56 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XtSB2-0000Ap-4s for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Nov 2014 03:17:56 +0100 Original-Received: from localhost ([::1]:60184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSB1-0001YL-L6 for geh-help-gnu-emacs@m.gmane.org; Tue, 25 Nov 2014 21:17:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSAq-0001YD-3L for help-gnu-emacs@gnu.org; Tue, 25 Nov 2014 21:17:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtSAp-0005lm-5Y for help-gnu-emacs@gnu.org; Tue, 25 Nov 2014 21:17:44 -0500 Original-Received: from mail-ig0-x234.google.com ([2607:f8b0:4001:c05::234]:41731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtSAo-0005lX-VS for help-gnu-emacs@gnu.org; Tue, 25 Nov 2014 21:17:43 -0500 Original-Received: by mail-ig0-f180.google.com with SMTP id h15so1853049igd.7 for ; Tue, 25 Nov 2014 18:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=fMQ2rBL2VWS6epa6vUFnDGgpvUpSpumD+VTHIsqx4wM=; b=oJu+9A4lxDxe3tQpDm2BFII5ERcfD2QnPyqTMWMvy8kzn/4eLFpsWdIuQviFSvXOaz 4ki+FZb2N+rKxU6CEk63s93UunlWeNIBB4Lp8QXlGBW9GMRvdcMNhc7RE4N1SFgSxdQ8 +QE2mbYABjRWll4XzBIQwpuOuFzMgsLT/fLa24B5fCLQVo19cpd727zQFFKI8oMMdZWM mecUxLwZIUrtxxHkNZY3WNeOTPVxAdGLp3FxYYKt11FsuXvdxgZgpPA5Lb25SoFr4LJk E50TB/8jDuJeo7/UJBNgTsvWuEPAk5E8ZhNQ9RNOZ1EusR1Un+hW1oiHLqg/O8llxfXn hvpQ== X-Received: by 10.43.73.71 with SMTP id yr7mr2451318icb.32.1416968262167; Tue, 25 Nov 2014 18:17:42 -0800 (PST) Original-Received: by 10.107.48.82 with HTTP; Tue, 25 Nov 2014 18:17:42 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: gLLbWiJEUyiQfbVY8Iwh6o9eQZc X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c05::234 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101202 Archived-At: On Tue, Nov 25, 2014 at 10:35 PM, Alexander Shukaev wr= ote: > `with-eval-after-load' is indeed very handy form. But currently I'm in th= e > situation where I need its counterpart --- `with-eval-before-load'. =E2=80=9Cwith-eval-after-load=E2=80=9D is possible because time flows forwa= rd. 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 =E2=80=9Cwith-eval-before-load=E2=80=9D 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=E2=80=99re out of luck. Try as we might, we cannot execute FORM *before* loading MODULE =E2=80=94 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=E2=80=99s precisely what you=E2=80=99= re trying to solve with =E2=80=9Cwith-eval-before-load=E2=80=9D =E2=80=94 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.