6

My understanding is if that I use any of :commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, or :interpreter, then it will create a corresponding autoload and defer loading of the package until that autoload is triggered.

I'm confused about the situations in which the package will load given that I don't use any of the above sections and I set it to :defer t.

I see this in the readme:

Typically, you only need to specify :defer if you know for a fact that some other package will do something to cause your package to load at the appropriate time, and thus you would like to defer loading even though use-package isn't creating any autoloads for you.

If I know for a fact that package X has "built-in" autoloads (i.e. autoloads defined by the package author), then can I simply set :defer t and rely on those to load the package at the appropriate time?

Jorge Israel Peña
  • 1,265
  • 9
  • 17

1 Answers1

5

If I know for a fact that package X has "built-in" autoloads (i.e. autoloads defined by the package author), then can I simply set :defer t and rely on those to load the package at the appropriate time?

Yes, that's exactly what that means. Similarly, you can also use :defer t in place of something like :mode or :interpreter if the package already handles its auto-mode-alist or interpreter-mode-alist assignments correctly.

Aaron Harris
  • 2,664
  • 17
  • 22
  • 1
    Thank you! Do you know if there's a more convenient and reliable way to see if a package contains autoloads than scouring through the package's directory in my elpa/ dir and looking to see if there are any autoloads defined? I'm confused because I get the impression that this is [done automatically](http://stackoverflow.com/a/26363815/101090) if I use package.el and MELPA (which I do), so does that mean that I can safely specify `:defer t` on all of the packages I install from MELPA? – Jorge Israel Peña Jan 20 '16 at 20:00
  • 2
    What I do is use `describe-function` (`C-h f`) on whatever command I'd like to use as an entry point. If it's been natively autoloaded (i.e., as part of the package rather than your `use-package` declaration), the help buffer will describe it as something like "an autoloaded compiled Lisp function" in the first line. And yes, the autoloads should be set up automatically by package.el. – Aaron Harris Jan 20 '16 at 20:40