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: Tue, 16 May 2023 18:40:55 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

David Masterson <dsmasterson@gmail.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: David Masterson <dsmasterson@gmail.com>
>>> Cc: help-gnu-emacs@gnu.org
>>> Date: Mon, 15 May 2023 15:27:53 -0700
>>> 
>>> Eli Zaretskii <eliz@gnu.org> writes:
>>> 
>>> >> From: David Masterson <dsmasterson@gmail.com>
>>> >> Cc: help-gnu-emacs@gnu.org
>>> >> Date: Sun, 14 May 2023 23:16:52 -0700
>>> >> 
>>> >> If a, b, and c were all ':defer t' and a had ':bind ("C-." . b-mode)'
>>> >> and I later hit that key, that would load c, then b, then a -- right?
>>> >
>>> > No, based on my reading of the docs I think it will cause an error
>>> > (because b cannot be loaded without c being loaded).
>>> 
>>> D**n typo -- it should've been 'a-mode'.
>>
>> I don't think it matters.  AFAIU, :bind doesn't load the package
>> except via explicit autoloads (i.e. not via use-package machinery).
>
> I think we're saying the same thing.  The bound key will call 'a-mode
> which will trigger the autoload setup by use-package because a was
> deferred. 
>
>>> My question was that the :bind key would force the load of the
>>> bottom of the tree and the :afters would then force loading of the
>>> parent packages.
>>
>> :after cannot force loading the parents, AFAIU.  I don't understand
>> why you think it should (or could).
>
> The :after(s) say there is a relationship between a, b, and c --
> presumably, in the user's setup, a won't be used without b (same w/
> b->c).  Therefore, if the :after on a doesn't kick the loading of the
> deferred b, then it must be assumed that a does (require 'b) (and
> similar b->c) in which case is there a need for :after? Each package
> would handle it internally via 'require'.
>
> I'm assuming there is a reason for :after in the case where a, b, and c
> are not directly related (ie. no internal requires), but are related
> because of the user's environment.  For instance, a (made up) example
> might be when the user brings in (say) a specialized spell checker then
> he's going to work with Org (ie. (use-package checker :after org)).  In
> this case, the spell checker would hook itself into Org -- Org would not
> know anything else about it.
>
> Does that make sense?

Ultimately, I think two statements should be made about :after in the
documentation: 

1. :demand/:defer are meaningless when :after is present.
2. :after ensures that the current package is loaded after the listed
   packages (which is different than failing if the listed packages are
   not already loaded when loading the current package).  The current
   package may load immediately because the listed packages are already
   loaded or use-package will setup "magic" to autoload this package
   when the listed packages have been loaded.

That's a little more wordy than I wanted.

With respect to :requires, it's explicitly says that it happens at time
of use-package call which is fine.

With respect to :if (etc.), it doesn't explicitly say, but it's implied
by the docs for :requires.  It should probably be explicit.

Does this make sense?

-- 
David Masterson



reply via email to

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