Installing package
The :ensure keyword makes use-package ask the Emacs package manager to install a package if it is not already present on your system.
For example:
(use-package magit
:ensure t)If you need to install a different package from the one named by use-package, you can use a symbol:
(use-package tex
:ensure auctex)You can customize the user option use-package-always-ensure to a non-nil value if you want this behavior to be global for all packages:
(require 'use-package-ensure)
(setq use-package-always-ensure t)You can override the above setting for a single package by adding :ensure nil to its declaration.
The :vc keyword can be used to control how packages are downloaded and/or installed. More specifically, it allows one to fetch and update packages directly from a version control system. This is especially convenient when wanting to install a package that is not on any package archive.
The keyword accepts the same arguments as specified in see Fetching Package Sources in GNU Emacs Manual, except that a name need not explicitly be given: it is inferred from the declaration. The accepted property list is augmented by a :rev keyword, which has the same shape as the REV argument to package-vc-install. Notably – even when not specified – :rev defaults to checking out the last release of the package. You can use :rev :newest to check out the latest commit. Note that currently, you cannot upgrade built-in packages using :vc.
For example,
(use-package bbdb
:vc "https://git.savannah.nongnu.org/git/bbdb.git")will check out the latest release commit using package-vc-install, while
(use-package bbdb
:vc (:url "https://git.savannah.nongnu.org/git/bbdb.git"
:rev :newest))would try to install the latest commit of the package foo from the specified remote.
Alternatively, the use-package-vc-prefer-newest user option exists to always prefer the latest commit.