You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I.e. a hook that runs immediately after the last-to-be-configured package of all current use-package definitions is configured. The name can be something else.
One use case is adding an element to a list with meaningful order, such as emulation-mode-map-alists, such that one wants to have it as the first element. Modifying such a list only after all packages have been loaded and configured decreases the chance that such an undesirable override happens.
Given that I use (setopt use-package-compute-statistics t), these are the problematic alternatives I've considered:
In init.el, putting the following after all other usages of use-package:
(eval
`(use-package
my-virtual-package
:after
,(copy-tree (hash-table-keys use-package-statistics))
:config (message"I'm running my code after all use-package declarations have run their configuration!")
:no-requiret))
In my case, (length (hash-table-keys use-package-statistics)) is 152.
"Map" (hash-table-keys use-package-statistics) into multiple nested eval-after-loads:
It doesn't meet my needs: this will run after the last package is loaded. What I want is to run after the last package is configured.
Assume that at least one package managed by use-package has not yet been loaded by the end of init.el (this assumption breaks, for example, if one uses :demand t in all of their use-package declarations). One can adviceuse-package-statistics-gather at the end of their init.el like so:
(advice-add'use-package-statistics-gather:after
(lambda (&rest_)
(when (cl-every
(lambda (use-package-statistic)
(equal
(use-package-statistics-status
use-package-statistic)
"Configured"))
(hash-table-values use-package-statistics))
(message"I'm running my code after all use-package declarations have run their configuration!"))))))
This is roughly what I'm doing and works fine, but, as is typical with pieces of advice, relies on fragile assumptions (i.e. that are easy to be broken by code updates to this repository) about the internal workings of use-package, e.g. the fact that this is the only function that calls (puthash KEY VALUE use-package-statistics).
The text was updated successfully, but these errors were encountered:
I.e. a hook that runs immediately after the last-to-be-configured package of all current
use-package
definitions is configured. The name can be something else.One use case is adding an element to a list with meaningful order, such as
emulation-mode-map-alists
, such that one wants to have it as the first element. Modifying such a list only after all packages have been loaded and configured decreases the chance that such an undesirable override happens.Given that I use
(setopt use-package-compute-statistics t)
, these are the problematic alternatives I've considered:In
init.el
, putting the following after all other usages ofuse-package
:This does not work if one is has a lot
use-package
declarations; one encounters this errorhttps://github.com/emacs-mirror/emacs/blob/c4541a35770fe7925f733fcdaa9e4e3348a3c85c/src/fns.c#L2754
In my case,
(length (hash-table-keys use-package-statistics))
is 152."Map"
(hash-table-keys use-package-statistics)
into multiple nestedeval-after-load
s:It doesn't meet my needs: this will run after the last package is loaded. What I want is to run after the last package is configured.
Assume that at least one package managed by
use-package
has not yet been loaded by the end ofinit.el
(this assumption breaks, for example, if one uses:demand t
in all of theiruse-package
declarations). One canadvice
use-package-statistics-gather
at the end of theirinit.el
like so:This is roughly what I'm doing and works fine, but, as is typical with pieces of
advice
, relies on fragile assumptions (i.e. that are easy to be broken by code updates to this repository) about the internal workings ofuse-package
, e.g. the fact that this is the only function that calls(puthash KEY VALUE use-package-statistics)
.The text was updated successfully, but these errors were encountered: