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

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

Re: use-package :after ??


From: David Masterson
Subject: Re: use-package :after ??
Date: Wed, 10 May 2023 16:56:35 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi Eli,

I'm still confused about where the problem is, but I'll try to explain.

Eli Zaretskii <eliz@gnu.org> writes:

>> From: David Masterson <dsmasterson@gmail.com>
>> Date: Sun, 07 May 2023 17:05:57 -0700
>> 
>> This might be a documentation problem...

I have a fairly lengthy .emacs (probably nowhere near as complex as
yours) that I've setup use-package to speed up starting Emacs.  I've
(mostly) alphabetized my packages and use-package them in sequence.
I've set to deferred loading and I'm using :after to get subpackages to
load when the main package loads (ie: org-ac <- org).

My current problem is that org-ac is not loading after first using org
even though I've the :after flag on org-ac.  If I hand load og-ac,
everthing is fine.

>> I'm not sure I understand ":after" (and a few other related things) in
>> use-package.  The info docs talk about it ensuring that the current
>> package is loaded after the other listed packages, but it's not quite
>> explicit (to me) about what that means.  I interpret it in two possible
>> ways:

The key section is 3.5 in use-package infodoc.

>> 1. If any of the listed packages are not loaded currently, then the
>> current package will not be loaded. Period.
>> 2. #1 + "magic" will be done to ensure that, once the listed packages
>> are loaded, the current package will be (auto?) loaded.
>
> Which parts of the documentation make the answer to this question less
> than obvious?  There should be no need to expand the use-package
> macros to understand what it is doing; just reading the documentation
> should be enough (and it is for me, FWIW).

Section 3.1 talks about load and autoload, but could be extended to talk
about how use-package uses autoload to make things happen -- at least by
mentioning what use-package things (like :con fig) will happen at
autoload versus when the use-package is called.

In section 3.5, the first sentence talks about "configure", but
shouldn't it really be "load and configure"?  Also, the example is not
really good because it says that "‘:after’ is not strictly necessary" in
this case.  Better to reverse it and say what will happen in both the
demand and defered cases (I don't use it, but I guess this should also
be done in 3.4 and 3.6). 

>> My goal is to organize my .emacs loading of 25+ packages to only load if
>> needed.  That means (almost) all packages are deferred at startup and
>> will load itself and subpackages (minor modes, etc.) when I try to call
>> the package.  This is what I hoped :after was for.
>
> AFAIU, :after is not about deferral, it's about the conditions to
> load.  use-package has other features for deferral, like :defer and
> use-package-always-defer.
>
> And for loading when needed you have autoloads, of course.

Yes, :after is about when to load.  I'm looking to figure out why org-ac
didn't load when I needed for org. I need more time to play with it.

>> Can someone advise on the proper use of ":after" and how to get
>> appropriate subpackages to also load when the main package is loaded.
>> For instance:
>> 
>> (use-package org-ac :after org)
>> (use-package org)
>
> What is unclear or not self-evident about the above?

>From the macroexpand, I now understand some of the "magic" of autoload.
I'm still missing how the :config (etc.) happens after the autoload to
ensure that the package is configured.  That's important in helping me
look for side-effects in the :config that didn't work with autoload
(ie. I need :demand somewhere).

-- 
David Masterson



reply via email to

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