jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.39k stars 259 forks source link

Many packages fail to lazy load #951

Closed mcandre closed 1 year ago

mcandre commented 3 years ago

Half of the packages in my .emacs file fail to lazy load. For some reason, use-package is trying to load them aggressively early.

https://github.com/mcandre/dotfiles/blob/master/.emacs

I even have to manually (package-install '<package>) to fix them! Instead of use-package installing them.

progfolio commented 2 years ago

You don't mention which packages you think are being loaded too early. You have many forms like this in your init:

(use-package apache-mode)
(use-package clojure-mode)
(use-package coffee-mode)
(use-package cmake-mode)

If you're expecting these to be lazy loaded, you should take a look again at the documentation. Certain keywords imply deferred loading, but not using any (as above) will immediately load the package. use-package is a macro, so you can use macroexpand to see the code it expands to. I suggest doing for any declarations you think aren't being loaded properly.

matta commented 2 years ago

Yes, you'll want at minimum (use-package cmake-mode :defer t) for deferred loading.

Be careful, if use-package-always-ensure is false, which is the default, that form will expand to code that does nothing! With use-package-always-ensure true, as you have in your config, that should cause use-package to ensure the package is installed, but it won't load the package.

Try M-x pp-macroexpand-last-sexp when at the end of a use-package form to see what it does.

skangas commented 1 year ago

It seems like this support question was resolved by the above replies, so I'm closing this now.