Skip to content

Commit

Permalink
Update documentation for :defer t
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Feb 28, 2018
1 parent 29c78ce commit e2b1cec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
19 changes: 14 additions & 5 deletions doc/LAYERS.org
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ The aspiring layer author is recommended to have a look at the =use-package=
This simply loads Helm. It is essentially equivalent to =(require 'helm)=.

#+begin_src emacs-lisp
(use-package helm
:defer t)
(use-package helm)
#+end_src

This defers the loading of Helm using the auto-load facility and the auto-load
commands provided by the Helm source code. It is, in fact, a no-op.
By default =use-package= will try to defer the loading of the packages by using
the auto-load facility and the auto-load commands provided by the package source
code. So actually in the example above the code won't load =Helm= until one of
the auto-loaded functions is called.

#+begin_src emacs-lisp
(use-package helm
:defer t
:init
;; Code to execute before Helm is loaded
:config
Expand All @@ -251,6 +251,15 @@ section is not executed until after loading, if ever. It is essentially
equivalent to simply running the =:init= block, and then adding the =:config=
block in an =with-eval-after-load=.

#+begin_src emacs-lisp
(use-package helm
:demand t)
#+end_src

=:demand t= will force the package to be fully loaded right away. It
effectively disable lazy loading.


#+begin_src emacs-lisp
(use-package helm
:commands (helm-find-files helm-M-x))
Expand Down
8 changes: 3 additions & 5 deletions doc/VIMUSERS.org
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,12 @@ that allows easy lazy-loading and configuration of packages. Here are the basics
to using it:

#+BEGIN_SRC emacs-lisp
;; Basic form of use-package declaration. The :defer t tells use-package to
;; try to lazy load the package.
(use-package package-name
:defer t)
;; Basic form of use-package declaration. By default the package will be
;; lazy loaded.
(use-package package-name)
;; The :init section is run before the package loads. The :config section is
;; run after the package loads
(use-package package-name
:defer t
:init
(progn
;; Change some variables
Expand Down
1 change: 0 additions & 1 deletion layers/+completion/auto-completion/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ In the file =packages.el= of the python layer:

(defun python/init-company-anaconda ()
(use-package company-anaconda
:defer t
:init
(spacemacs|add-company-backends
:backends company-anaconda
Expand Down

0 comments on commit e2b1cec

Please sign in to comment.