2

How can I defer loading a package when it is installed using package.el with use-package? Basically, I want the package I use to only be activated using use-package instead of package-initialize so that this snippet would produce an error:

(use-package company
  :init
  (global-company-mode)
  (message "Company mode enabled globally"))

(and changing :init to :config would work as expected)

mkcms
  • 1,340
  • 12
  • 13

2 Answers2

2

I have found the answer here: Using package.el to install and update but use-package for loading and configuring

Basically, you can use package.el to manage packages and call (package-initialize t) to setup load paths but not activate them.

mkcms
  • 1,340
  • 12
  • 13
1

while I don't know the specific answer to your question, use_package supports :defer n which will defer loading the package containing :defer for n seconds.

there is also :disabled which may be of help to you.

As a complete example, the use-package author John Wiegley uses this snippet for which-key:

(use-package which-key
  :disabled t
  :load-path "site-lisp/which-key"
  :diminish which-key-mode
  :commands which-key-mode
  :defer 10
  :config
  (which-key-mode 1))
jeffmcc
  • 221
  • 1
  • 6