Skip to content

Commit

Permalink
Add very basic use-package tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
person808 committed May 14, 2015
1 parent 6081db8 commit db364e6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions doc/VIMUSERS.org
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,46 @@ pattern as packages.

Make sure you [[*Activating%20a%20Layer][add]] your layer to your =.dotspacemacs= file and restart to
activate it.
** Installing a single package
Sometimes creating a layer is a bit overkill. Maybe you just want one package
and don't want to maintain a whole layer. Spacemacs provides a variable in the
=dotspacemacs/init= function in =.spacemacs= called
=dotspacemacs-additional-packages=. Just add a package name to the list and it
will be installed when you restart. Loading the package is covered in the next [[*Loading%20packages][section.]]

** Loading packages
Ever wonder how Spacemacs can load over a 100 packages in just a few seconds?
Such low loading times must require some kind of unreadable black magic that no
one can understand. Thanks to [[https://github.com/jwiegley/use-package][use-package]], this is not true. It is a package
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)
;; 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
(setq variable1 t
variable2 nil)
;; Define a function
(defun foo ()
(message "%s" "Hello, World!")))
:config
(progn
;; Calling a function that is defined when the package loads
(function-defined-when-package-loads)))
#+end_src

This is just a very basic overview of =use-package=. There are many other ways
to control how a package loads using it that aren't covered here.
** Common tweaks
This section is for things almost everyone will want to change. All of these
settings go in the =dotspacemacs/config= function in your =.spacemacs= unless
otherwise noted.

0 comments on commit db364e6

Please sign in to comment.