]> code.delx.au - gnu-emacs/blob - doc/emacs/package.texi
5f80b0afe3f83ca172e79395215d8186a1cc0c84
[gnu-emacs] / doc / emacs / package.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2015 Free Software
3 @c Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Packages
6 @chapter Emacs Lisp Packages
7 @cindex Package
8 @cindex Emacs Lisp package archive
9 @cindex Package archive
10 @cindex Emacs Lisp package
11
12 Emacs includes a facility that lets you easily download and install
13 @dfn{packages} that implement additional features. Each package is a
14 separate Emacs Lisp program, sometimes including other components such
15 as an Info manual.
16
17 @kbd{M-x list-packages} brings up a buffer named @file{*Packages*}
18 with a list of all packages. You can install or uninstall packages
19 via this buffer. @xref{Package Menu}.
20
21 @findex describe-package
22 The command @kbd{C-h P} (@code{describe-package}) prompts for the
23 name of a package, and displays a help buffer describing the
24 attributes of the package and the features that it implements.
25
26 By default, Emacs downloads packages from a @dfn{package archive}
27 maintained by the Emacs developers and hosted by the GNU project.
28 Optionally, you can also download packages from archives maintained by
29 third parties. @xref{Package Installation}.
30
31 For information about turning an Emacs Lisp program into an
32 installable package, @xref{Packaging,,,elisp, The Emacs Lisp Reference
33 Manual}.
34
35 @menu
36 * Package Menu:: Buffer for viewing and managing packages.
37 * Package Installation:: Options for package installation.
38 * Package Files:: Where packages are installed.
39 @end menu
40
41 @node Package Menu
42 @section The Package Menu Buffer
43 @cindex package menu
44 @cindex built-in package
45 @findex list-packages
46
47 The command @kbd{M-x list-packages} brings up the @dfn{package menu}.
48 This is a buffer listing all the packages that Emacs knows about, one
49 on each line, with the following information:
50
51 @itemize @bullet
52 @item
53 The package name (e.g., @samp{auctex}).
54
55 @item
56 The package's version number (e.g., @samp{11.86}).
57
58 @item
59 The package's status---normally one of @samp{available} (can be
60 downloaded from the package archive), @samp{installed},
61 @c @samp{unsigned} (installed, but not signed; @pxref{Package Signing}),
62 or @samp{built-in} (included in Emacs by default). The status
63 @samp{external} means the package is not built-in and not from the
64 directory specified by @code{package-user-dir} (@pxref{Package
65 Files}). External packages are treated much like built-in: they
66 cannot be deleted through the package menu, and are not considered for
67 upgrading.
68
69 The status can also be @samp{new}. This is equivalent to
70 @samp{available}, except that it means the package became newly
71 available on the package archive after your last invocation of
72 @kbd{M-x list-packages}. In other instances, a package may have the
73 status @samp{held}, @samp{disabled}, or @samp{obsolete}.
74 @xref{Package Installation}.
75
76 @item
77 A short description of the package.
78 @end itemize
79
80 @noindent
81 The @code{list-packages} command accesses the network, to retrieve the
82 list of available packages from the package archive server. If the
83 network is unavailable, it falls back on the most recently retrieved
84 list.
85
86 The following commands are available in the package menu:
87
88 @table @kbd
89 @item h
90 Print a short message summarizing how to use the package menu
91 (@code{package-menu-quick-help}).
92
93 @item ?
94 @itemx @key{RET}
95 Display a help buffer for the package on the current line
96 (@code{package-menu-describe-package}), similar to the help window
97 displayed by the @kbd{C-h P} command (@pxref{Packages}).
98
99 @item i
100 Mark the package on the current line for installation
101 (@code{package-menu-mark-install}). If the package status is
102 @samp{available}, this adds an @samp{I} character to the start of the
103 line; typing @kbd{x} (see below) will download and install the
104 package.
105
106 @item d
107 Mark the package on the current line for deletion
108 (@code{package-menu-mark-delete}). If the package status is
109 @samp{installed}, this adds a @samp{D} character to the start of the
110 line; typing @kbd{x} (see below) will delete the package.
111 @xref{Package Files}, for information about what package deletion
112 entails.
113
114 @item ~
115 Mark all obsolete packages for deletion
116 (@code{package-menu-mark-obsolete-for-deletion}). This marks for
117 deletion all the packages whose status is @samp{obsolete}.
118
119 @item u
120 @itemx @key{DEL}
121 Remove any installation or deletion mark previously added to the
122 current line by an @kbd{i} or @kbd{d} command.
123
124 @item U
125 Mark all package with a newer available version for upgrading
126 (@code{package-menu-mark-upgrades}). This places an installation mark
127 on the new available versions, and a deletion mark on the old
128 installed versions.
129
130 @item x
131 @vindex package-menu-async
132 Download and install all packages marked with @kbd{i}, and their
133 dependencies; also, delete all packages marked with @kbd{d}
134 (@code{package-menu-execute}). This also removes the marks.
135
136 @item r
137 Refresh the package list (@code{package-menu-refresh}). This fetches
138 the list of available packages from the package archive again, and
139 recomputes the package list.
140
141 @item f
142 Filter the package list (@code{package-menu-filter}). This prompts
143 for a keyword (e.g., @samp{games}), then shows only the packages
144 that relate to that keyword. To restore the full package list,
145 type @kbd{q}.
146
147 @item H
148 Permanently hide packages that match a regexp
149 (@code{package-menu-hide-package}).
150
151 @item (
152 Toggle visibility of old versions of packages and also of versions
153 from lower-priority archives (@code{package-menu-toggle-hiding}).
154 @end table
155
156 @noindent
157 For example, you can install a package by typing @kbd{i} on the line
158 listing that package, followed by @kbd{x}.
159
160 @node Package Installation
161 @section Package Installation
162
163 @findex package-install
164 Packages are most conveniently installed using the package menu
165 (@pxref{Package Menu}), but you can also use the command @kbd{M-x
166 package-install}. This prompts for the name of a package with the
167 @samp{available} status, then downloads and installs it.
168
169 @cindex package requirements
170 A package may @dfn{require} certain other packages to be installed,
171 because it relies on functionality provided by them. When Emacs
172 installs such a package, it also automatically downloads and installs
173 any required package that is not already installed. (If a required
174 package is somehow unavailable, Emacs signals an error and stops
175 installation.) A package's requirements list is shown in its help
176 buffer.
177
178 @vindex package-archives
179 By default, packages are downloaded from a single package archive
180 maintained by the Emacs developers. This is controlled by the
181 variable @code{package-archives}, whose value is a list of package
182 archives known to Emacs. Each list element must have the form
183 @code{(@var{id} . @var{location})}, where @var{id} is the name of a
184 package archive and @var{location} is the @acronym{HTTP} address or
185 directory name of the package archive. You can alter this list if you
186 wish to use third party package archives---but do so at your own risk,
187 and use only third parties that you think you can trust!
188
189 @anchor{Package Signing}
190 @cindex package security
191 @cindex package signing
192 The maintainers of package archives can increase the trust that you
193 can have in their packages by @dfn{signing} them. They generate a
194 private/public pair of cryptographic keys, and use the private key to
195 create a @dfn{signature file} for each package. With the public key, you
196 can use the signature files to verify who created the package, and
197 that it has not been modified. A valid signature is not a cast-iron
198 guarantee that a package is not malicious, so you should still
199 exercise caution. Package archives should provide instructions
200 on how you can obtain their public key. One way is to download the
201 key from a server such as @url{http://pgp.mit.edu/}.
202 Use @kbd{M-x package-import-keyring} to import the key into Emacs.
203 Emacs stores package keys in the @file{gnupg} subdirectory
204 of @code{package-user-dir}.
205 The public key for the GNU package archive is distributed with Emacs,
206 in the @file{etc/package-keyring.gpg}. Emacs uses it automatically.
207
208 @vindex package-check-signature
209 @vindex package-unsigned-archives
210 If the user option @code{package-check-signature} is non-@code{nil},
211 Emacs attempts to verify signatures when you install packages. If the
212 option has the value @code{allow-unsigned}, you can still install a
213 package that is not signed. If you use some archives that do not sign
214 their packages, you can add them to the list @code{package-unsigned-archives}.
215
216 For more information on cryptographic keys and signing,
217 @pxref{Top,, Top, gnupg, The GNU Privacy Guard Manual}.
218 Emacs comes with an interface to GNU Privacy Guard,
219 @pxref{Top,, EasyPG, epa, Emacs EasyPG Assistant Manual}.
220
221 @vindex package-pinned-packages
222 If you have more than one package archive enabled, and some of them
223 offer different versions of the same package, you may find the option
224 @code{package-pinned-packages} useful. You can add package/archive
225 pairs to this list, to ensure that the specified package is only ever
226 downloaded from the specified archive.
227
228 @vindex package-archive-priorities
229 @vindex package-menu-hide-low-priority
230 Another option that is useful when you have several package archives
231 enabled is @code{package-archive-priorities}. It specifies the
232 priority of each archive (higher numbers specify higher priority
233 archives). By default, archives have the priority of zero, unless
234 specified otherwise by this option's value. Packages from
235 lower-priority archives will not be shown in the menu, if the same
236 package is available from a higher-priority archive. (This is
237 controlled by the value of @code{package-menu-hide-low-priority}.)
238
239 Once a package is downloaded and installed, it is @dfn{loaded} into
240 the current Emacs session. Loading a package is not quite the same as
241 loading a Lisp library (@pxref{Lisp Libraries}); its effect varies
242 from package to package. Most packages just make some new commands
243 available, while others have more wide-ranging effects on the Emacs
244 session. For such information, consult the package's help buffer.
245
246 By default, Emacs also automatically loads all installed packages in
247 subsequent Emacs sessions. This happens at startup, after processing
248 the init file (@pxref{Init File}). As an exception, Emacs does not
249 load packages at startup if invoked with the @samp{-q} or
250 @samp{--no-init-file} options (@pxref{Initial Options}).
251
252 @vindex package-enable-at-startup
253 To disable automatic package loading, change the variable
254 @code{package-enable-at-startup} to @code{nil}.
255
256 @findex package-initialize
257 The reason automatic package loading occurs after loading the init
258 file is that user options only receive their customized values after
259 loading the init file, including user options which affect the
260 packaging system. In some circumstances, you may want to load
261 packages explicitly in your init file (usually because some other code
262 in your init file depends on a package). In that case, your init file
263 should call the function @code{package-initialize}. It is up to you
264 to ensure that relevant user options, such as @code{package-load-list}
265 (see below), are set up prior to the @code{package-initialize} call.
266 This will automatically set @code{package-enable-at-startup} to @code{nil}, to
267 avoid loading the packages again after processing the init file.
268 Alternatively, you may choose to completely inhibit package loading at
269 startup, and invoke the command @kbd{M-x package-initialize} to load
270 your packages manually.
271
272 @vindex package-load-list
273 For finer control over package loading, you can use the variable
274 @code{package-load-list}. Its value should be a list. A list element
275 of the form @code{(@var{name} @var{version})} tells Emacs to load
276 version @var{version} of the package named @var{name}. Here,
277 @var{version} should be a version string (corresponding to a specific
278 version of the package), or @code{t} (which means to load any
279 installed version), or @code{nil} (which means no version; this
280 disables the package, preventing it from being loaded). A list
281 element can also be the symbol @code{all}, which means to load the
282 latest installed version of any package not named by the other list
283 elements. The default value is just @code{'(all)}.
284
285 For example, if you set @code{package-load-list} to @code{'((muse
286 "3.20") all)}, then Emacs only loads version 3.20 of the @samp{muse}
287 package, plus any installed version of packages other than
288 @samp{muse}. Any other version of @samp{muse} that happens to be
289 installed will be ignored. The @samp{muse} package will be listed in
290 the package menu with the @samp{held} status.
291
292 @node Package Files
293 @section Package Files and Directory Layout
294 @cindex package directory
295
296 @cindex package file
297 @findex package-install-file
298 Each package is downloaded from the package archive in the form of a
299 single @dfn{package file}---either an Emacs Lisp source file, or a tar
300 file containing multiple Emacs Lisp source and other files. Package
301 files are automatically retrieved, processed, and disposed of by the
302 Emacs commands that install packages. Normally, you will not need to
303 deal directly with them, unless you are making a package
304 (@pxref{Packaging,,,elisp, The Emacs Lisp Reference Manual}). Should
305 you ever need to install a package directly from a package file, use
306 the command @kbd{M-x package-install-file}.
307
308 @vindex package-user-dir
309 Once installed, the contents of a package are placed in a
310 subdirectory of @file{~/.emacs.d/elpa/} (you can change the name of
311 that directory by changing the variable @code{package-user-dir}). The
312 package subdirectory is named @file{@var{name}-@var{version}}, where
313 @var{name} is the package name and @var{version} is its version
314 string.
315
316 @cindex system-wide packages
317 @vindex package-directory-list
318 In addition to @code{package-user-dir}, Emacs looks for installed
319 packages in the directories listed in @code{package-directory-list}.
320 These directories are meant for system administrators to make Emacs
321 packages available system-wide; Emacs itself never installs packages
322 there. The package subdirectories for @code{package-directory-list}
323 are laid out in the same way as in @code{package-user-dir}.
324
325 Deleting a package (@pxref{Package Menu}) involves deleting the
326 corresponding package subdirectory. This only works for packages
327 installed in @code{package-user-dir}; if told to act on a package in a
328 system-wide package directory, the deletion command signals an error.