Next: Package Files, Previous: Package Menu, Up: Packages [Contents][Index]
Packages are most conveniently installed using the package menu (see Package Menu), but you can also use the command M-x package-install. This prompts for the name of a package with the ‘available’ status, then downloads and installs it.
A package may require certain other packages to be installed, because it relies on functionality provided by them. When Emacs installs such a package, it also automatically downloads and installs any required package that is not already installed. (If a required package is somehow unavailable, Emacs signals an error and stops installation.) A package’s requirements list is shown in its help buffer.
By default, packages are downloaded from a single package archive
maintained by the Emacs developers. This is controlled by the
variable package-archives
, whose value is a list of package
archives known to Emacs. Each list element must have the form
(id . location)
, where id is the name of a
package archive and location is the HTTP address or
directory name of the package archive. You can alter this list if you
wish to use third party package archives—but do so at your own risk,
and use only third parties that you think you can trust!
Once a package is downloaded and installed, it is loaded into the current Emacs session. Loading a package is not quite the same as loading a Lisp library (see Lisp Libraries); its effect varies from package to package. Most packages just make some new commands available, while others have more wide-ranging effects on the Emacs session. For such information, consult the package’s help buffer.
By default, Emacs also automatically loads all installed packages in subsequent Emacs sessions. This happens at startup, after processing the init file (see Init File). As an exception, Emacs does not load packages at startup if invoked with the ‘-q’ or ‘--no-init-file’ options (see Initial Options).
To disable automatic package loading, change the variable
package-enable-at-startup
to nil
.
The reason automatic package loading occurs after loading the init
file is that user options only receive their customized values after
loading the init file, including user options which affect the
packaging system. In some circumstances, you may want to load
packages explicitly in your init file (usually because some other code
in your init file depends on a package). In that case, your init file
should call the function package-initialize
. It is up to you
to ensure that relevant user options, such as package-load-list
(see below), are set up prior to the package-initialize
call.
You should also set package-enable-at-startup
to nil
, to
avoid loading the packages again after processing the init file.
Alternatively, you may choose to completely inhibit package loading at
startup, and invoke the command M-x package-initialize to load
your packages manually.
For finer control over package loading, you can use the variable
package-load-list
. Its value should be a list. A list element
of the form (name version)
tells Emacs to load
version version of the package named name. Here,
version should be a version string (corresponding to a specific
version of the package), or t
(which means to load any
installed version), or nil
(which means no version; this
“disables” the package, preventing it from being loaded). A list
element can also be the symbol all
, which means to load the
latest installed version of any package not named by the other list
elements. The default value is just '(all)
.
For example, if you set package-load-list
to '((muse
"3.20") all)
, then Emacs only loads version 3.20 of the ‘muse’
package, plus any installed version of packages other than
‘muse’. Any other version of ‘muse’ that happens to be
installed will be ignored. The ‘muse’ package will be listed in
the package menu with the ‘held’ status.
Next: Package Files, Previous: Package Menu, Up: Packages [Contents][Index]