]> code.delx.au - gnu-emacs/blob - lisp/emacs-lisp/package.el
Merge from mainline.
[gnu-emacs] / lisp / emacs-lisp / package.el
1 ;;; package.el --- Simple package system for Emacs -*- lexical-binding:t -*-
2
3 ;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
4
5 ;; Author: Tom Tromey <tromey@redhat.com>
6 ;; Daniel Hackney <dan@haxney.org>
7 ;; Created: 10 Mar 2007
8 ;; Version: 1.0.1
9 ;; Keywords: tools
10 ;; Package-Requires: ((tabulated-list "1.0"))
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26
27 ;;; Change Log:
28
29 ;; 2 Apr 2007 - now using ChangeLog file
30 ;; 15 Mar 2007 - updated documentation
31 ;; 14 Mar 2007 - Changed how obsolete packages are handled
32 ;; 13 Mar 2007 - Wrote package-install-from-buffer
33 ;; 12 Mar 2007 - Wrote package-menu mode
34
35 ;;; Commentary:
36
37 ;; The idea behind package.el is to be able to download packages and
38 ;; install them. Packages are versioned and have versioned
39 ;; dependencies. Furthermore, this supports built-in packages which
40 ;; may or may not be newer than user-specified packages. This makes
41 ;; it possible to upgrade Emacs and automatically disable packages
42 ;; which have moved from external to core. (Note though that we don't
43 ;; currently register any of these, so this feature does not actually
44 ;; work.)
45
46 ;; A package is described by its name and version. The distribution
47 ;; format is either a tar file or a single .el file.
48
49 ;; A tar file should be named "NAME-VERSION.tar". The tar file must
50 ;; unpack into a directory named after the package and version:
51 ;; "NAME-VERSION". It must contain a file named "PACKAGE-pkg.el"
52 ;; which consists of a call to define-package. It may also contain a
53 ;; "dir" file and the info files it references.
54
55 ;; A .el file is named "NAME-VERSION.el" in the remote archive, but is
56 ;; installed as simply "NAME.el" in a directory named "NAME-VERSION".
57
58 ;; The downloader downloads all dependent packages. By default,
59 ;; packages come from the official GNU sources, but others may be
60 ;; added by customizing the `package-archives' alist. Packages get
61 ;; byte-compiled at install time.
62
63 ;; At activation time we will set up the load-path and the info path,
64 ;; and we will load the package's autoloads. If a package's
65 ;; dependencies are not available, we will not activate that package.
66
67 ;; Conceptually a package has multiple state transitions:
68 ;;
69 ;; * Download. Fetching the package from ELPA.
70 ;; * Install. Untar the package, or write the .el file, into
71 ;; ~/.emacs.d/elpa/ directory.
72 ;; * Byte compile. Currently this phase is done during install,
73 ;; but we may change this.
74 ;; * Activate. Evaluate the autoloads for the package to make it
75 ;; available to the user.
76 ;; * Load. Actually load the package and run some code from it.
77
78 ;; Other external functions you may want to use:
79 ;;
80 ;; M-x list-packages
81 ;; Enters a mode similar to buffer-menu which lets you manage
82 ;; packages. You can choose packages for install (mark with "i",
83 ;; then "x" to execute) or deletion (not implemented yet), and you
84 ;; can see what packages are available. This will automatically
85 ;; fetch the latest list of packages from ELPA.
86 ;;
87 ;; M-x package-install-from-buffer
88 ;; Install a package consisting of a single .el file that appears
89 ;; in the current buffer. This only works for packages which
90 ;; define a Version header properly; package.el also supports the
91 ;; extension headers Package-Version (in case Version is an RCS id
92 ;; or similar), and Package-Requires (if the package requires other
93 ;; packages).
94 ;;
95 ;; M-x package-install-file
96 ;; Install a package from the indicated file. The package can be
97 ;; either a tar file or a .el file. A tar file must contain an
98 ;; appropriately-named "-pkg.el" file; a .el file must be properly
99 ;; formatted as with package-install-from-buffer.
100
101 ;;; Thanks:
102 ;;; (sorted by sort-lines):
103
104 ;; Jim Blandy <jimb@red-bean.com>
105 ;; Karl Fogel <kfogel@red-bean.com>
106 ;; Kevin Ryde <user42@zip.com.au>
107 ;; Lawrence Mitchell
108 ;; Michael Olson <mwolson@member.fsf.org>
109 ;; Sebastian Tennant <sebyte@smolny.plus.com>
110 ;; Stefan Monnier <monnier@iro.umontreal.ca>
111 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
112 ;; Phil Hagelberg <phil@hagelb.org>
113
114 ;;; ToDo:
115
116 ;; - a trust mechanism, since compiling a package can run arbitrary code.
117 ;; For example, download package signatures and check that they match.
118 ;; - putting info dirs at the start of the info path means
119 ;; users see a weird ordering of categories. OTOH we want to
120 ;; override later entries. maybe emacs needs to enforce
121 ;; the standard layout?
122 ;; - put bytecode in a separate directory tree
123 ;; - perhaps give users a way to recompile their bytecode
124 ;; or do it automatically when emacs changes
125 ;; - give users a way to know whether a package is installed ok
126 ;; - give users a way to view a package's documentation when it
127 ;; only appears in the .el
128 ;; - use/extend checkdoc so people can tell if their package will work
129 ;; - "installed" instead of a blank in the status column
130 ;; - tramp needs its files to be compiled in a certain order.
131 ;; how to handle this? fix tramp?
132 ;; - on emacs 21 we don't kill the -autoloads.el buffer. what about 22?
133 ;; - maybe we need separate .elc directories for various emacs versions
134 ;; and also emacs-vs-xemacs. That way conditional compilation can
135 ;; work. But would this break anything?
136 ;; - should store the package's keywords in archive-contents, then
137 ;; let the users filter the package-menu by keyword. See
138 ;; finder-by-keyword. (We could also let people view the
139 ;; Commentary, but it isn't clear how useful this is.)
140 ;; - William Xu suggests being able to open a package file without
141 ;; installing it
142 ;; - Interface with desktop.el so that restarting after an install
143 ;; works properly
144 ;; - Use hierarchical layout. PKG/etc PKG/lisp PKG/info
145 ;; ... except maybe lisp?
146 ;; - It may be nice to have a macro that expands to the package's
147 ;; private data dir, aka ".../etc". Or, maybe data-directory
148 ;; needs to be a list (though this would be less nice)
149 ;; a few packages want this, eg sokoban
150 ;; - package menu needs:
151 ;; ability to know which packages are built-in & thus not deletable
152 ;; it can sometimes print odd results, like 0.3 available but 0.4 active
153 ;; why is that?
154 ;; - Allow multiple versions on the server...?
155 ;; [ why bother? ]
156 ;; - Don't install a package which will invalidate dependencies overall
157 ;; - Allow something like (or (>= emacs 21.0) (>= xemacs 21.5))
158 ;; [ currently thinking, why bother.. KISS ]
159 ;; - Allow optional package dependencies
160 ;; then if we require 'bbdb', bbdb-specific lisp in lisp/bbdb
161 ;; and just don't compile to add to load path ...?
162 ;; - Our treatment of the info path is somewhat bogus
163
164 ;;; Code:
165
166 (eval-when-compile (require 'cl-lib))
167
168 (require 'tabulated-list)
169
170 (defgroup package nil
171 "Manager for Emacs Lisp packages."
172 :group 'applications
173 :version "24.1")
174
175 ;;;###autoload
176 (defcustom package-enable-at-startup t
177 "Whether to activate installed packages when Emacs starts.
178 If non-nil, packages are activated after reading the init file
179 and before `after-init-hook'. Activation is not done if
180 `user-init-file' is nil (e.g. Emacs was started with \"-q\").
181
182 Even if the value is nil, you can type \\[package-initialize] to
183 activate the package system at any time."
184 :type 'boolean
185 :group 'package
186 :version "24.1")
187
188 (defcustom package-load-list '(all)
189 "List of packages for `package-initialize' to load.
190 Each element in this list should be a list (NAME VERSION), or the
191 symbol `all'. The symbol `all' says to load the latest installed
192 versions of all packages not specified by other elements.
193
194 For an element (NAME VERSION), NAME is a package name (a symbol).
195 VERSION should be t, a string, or nil.
196 If VERSION is t, the most recent version is activated.
197 If VERSION is a string, only that version is ever loaded.
198 Any other version, even if newer, is silently ignored.
199 Hence, the package is \"held\" at that version.
200 If VERSION is nil, the package is not loaded (it is \"disabled\")."
201 :type '(repeat symbol)
202 :risky t
203 :group 'package
204 :version "24.1")
205
206 (defvar Info-directory-list)
207 (declare-function info-initialize "info" ())
208 (declare-function url-http-parse-response "url-http" ())
209 (declare-function lm-header "lisp-mnt" (header))
210 (declare-function lm-commentary "lisp-mnt" (&optional file))
211 (defvar url-http-end-of-headers)
212
213 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/"))
214 "An alist of archives from which to fetch.
215 The default value points to the GNU Emacs package repository.
216
217 Each element has the form (ID . LOCATION).
218 ID is an archive name, as a string.
219 LOCATION specifies the base location for the archive.
220 If it starts with \"http:\", it is treated as a HTTP URL;
221 otherwise it should be an absolute directory name.
222 (Other types of URL are currently not supported.)
223
224 Only add locations that you trust, since fetching and installing
225 a package can run arbitrary code."
226 :type '(alist :key-type (string :tag "Archive name")
227 :value-type (string :tag "URL or directory name"))
228 :risky t
229 :group 'package
230 :version "24.1")
231
232 (defcustom package-pinned-packages nil
233 "An alist of packages that are pinned to a specific archive
234
235 Each element has the form (SYM . ID).
236 SYM is a package, as a symbol.
237 ID is an archive name. This should correspond to an
238 entry in `package-archives'.
239
240 If the archive of name ID does not contain the package SYM, no
241 other location will be considered, which will make the
242 package unavailable."
243 :type '(alist :key-type (symbol :tag "Package")
244 :value-type (string :tag "Archive name"))
245 :risky t
246 :group 'package
247 :version "24.4")
248
249 (defconst package-archive-version 1
250 "Version number of the package archive understood by this file.
251 Lower version numbers than this will probably be understood as well.")
252
253 ;; We don't prime the cache since it tends to get out of date.
254 (defvar package-archive-contents nil
255 "Cache of the contents of the Emacs Lisp Package Archive.
256 This is an alist mapping package names (symbols) to
257 non-empty lists of `package-desc' structures.")
258 (put 'package-archive-contents 'risky-local-variable t)
259
260 (defcustom package-user-dir (locate-user-emacs-file "elpa")
261 "Directory containing the user's Emacs Lisp packages.
262 The directory name should be absolute.
263 Apart from this directory, Emacs also looks for system-wide
264 packages in `package-directory-list'."
265 :type 'directory
266 :risky t
267 :group 'package
268 :version "24.1")
269
270 (defcustom package-directory-list
271 ;; Defaults are subdirs named "elpa" in the site-lisp dirs.
272 (let (result)
273 (dolist (f load-path)
274 (and (stringp f)
275 (equal (file-name-nondirectory f) "site-lisp")
276 (push (expand-file-name "elpa" f) result)))
277 (nreverse result))
278 "List of additional directories containing Emacs Lisp packages.
279 Each directory name should be absolute.
280
281 These directories contain packages intended for system-wide; in
282 contrast, `package-user-dir' contains packages for personal use."
283 :type '(repeat directory)
284 :risky t
285 :group 'package
286 :version "24.1")
287
288 (defvar package--default-summary "No description available.")
289
290 (cl-defstruct (package-desc
291 ;; Rename the default constructor from `make-package-desc'.
292 (:constructor package-desc-create)
293 ;; Has the same interface as the old `define-package',
294 ;; which is still used in the "foo-pkg.el" files. Extra
295 ;; options can be supported by adding additional keys.
296 (:constructor
297 package-desc-from-define
298 (name-string version-string &optional summary requirements
299 &key kind archive &allow-other-keys
300 &aux
301 (name (intern name-string))
302 (version (version-to-list version-string))
303 (reqs (mapcar #'(lambda (elt)
304 (list (car elt)
305 (version-to-list (cadr elt))))
306 (if (eq 'quote (car requirements))
307 (nth 1 requirements)
308 requirements))))))
309 "Structure containing information about an individual package.
310 Slots:
311
312 `name' Name of the package, as a symbol.
313
314 `version' Version of the package, as a version list.
315
316 `summary' Short description of the package, typically taken from
317 the first line of the file.
318
319 `reqs' Requirements of the package. A list of (PACKAGE
320 VERSION-LIST) naming the dependent package and the minimum
321 required version.
322
323 `kind' The distribution format of the package. Currently, it is
324 either `single' or `tar'.
325
326 `archive' The name of the archive (as a string) whence this
327 package came.
328
329 `dir' The directory where the package is installed (if installed),
330 `builtin' if it is built-in, or nil otherwise."
331 name
332 version
333 (summary package--default-summary)
334 reqs
335 kind
336 archive
337 dir)
338
339 ;; Pseudo fields.
340 (defun package-desc-full-name (pkg-desc)
341 (format "%s-%s"
342 (package-desc-name pkg-desc)
343 (package-version-join (package-desc-version pkg-desc))))
344
345 (defun package-desc-suffix (pkg-desc)
346 (pcase (package-desc-kind pkg-desc)
347 (`single ".el")
348 (`tar ".tar")
349 (kind (error "Unknown package kind: %s" kind))))
350
351 ;; Package descriptor format used in finder-inf.el and package--builtins.
352 (cl-defstruct (package--bi-desc
353 (:constructor package-make-builtin (version summary))
354 (:type vector))
355 version
356 reqs
357 summary)
358
359 (defvar package--builtins nil
360 "Alist of built-in packages.
361 The actual value is initialized by loading the library
362 `finder-inf'; this is not done until it is needed, e.g. by the
363 function `package-built-in-p'.
364
365 Each element has the form (PKG . PACKAGE-BI-DESC), where PKG is a package
366 name (a symbol) and DESC is a `package--bi-desc' structure.")
367 (put 'package--builtins 'risky-local-variable t)
368
369 (defvar package-alist nil
370 "Alist of all packages available for activation.
371 Each element has the form (PKG . DESCS), where PKG is a package
372 name (a symbol) and DESCS is a non-empty list of `package-desc' structure,
373 sorted by decreasing versions.
374
375 This variable is set automatically by `package-load-descriptor',
376 called via `package-initialize'. To change which packages are
377 loaded and/or activated, customize `package-load-list'.")
378 (put 'package-alist 'risky-local-variable t)
379
380 (defvar package-activated-list nil
381 ;; FIXME: This should implicitly include all builtin packages.
382 "List of the names of currently activated packages.")
383 (put 'package-activated-list 'risky-local-variable t)
384
385 (defun package-version-join (vlist)
386 "Return the version string corresponding to the list VLIST.
387 This is, approximately, the inverse of `version-to-list'.
388 \(Actually, it returns only one of the possible inverses, since
389 `version-to-list' is a many-to-one operation.)"
390 (if (null vlist)
391 ""
392 (let ((str-list (list "." (int-to-string (car vlist)))))
393 (dolist (num (cdr vlist))
394 (cond
395 ((>= num 0)
396 (push (int-to-string num) str-list)
397 (push "." str-list))
398 ((< num -3)
399 (error "Invalid version list `%s'" vlist))
400 (t
401 ;; pre, or beta, or alpha
402 (cond ((equal "." (car str-list))
403 (pop str-list))
404 ((not (string-match "[0-9]+" (car str-list)))
405 (error "Invalid version list `%s'" vlist)))
406 (push (cond ((= num -1) "pre")
407 ((= num -2) "beta")
408 ((= num -3) "alpha"))
409 str-list))))
410 (if (equal "." (car str-list))
411 (pop str-list))
412 (apply 'concat (nreverse str-list)))))
413
414 (defun package-load-descriptor (pkg-dir)
415 "Load the description file in directory PKG-DIR."
416 (let ((pkg-file (expand-file-name (package--description-file pkg-dir)
417 pkg-dir)))
418 (when (file-exists-p pkg-file)
419 (with-temp-buffer
420 (insert-file-contents pkg-file)
421 (goto-char (point-min))
422 (let ((pkg-desc (package-process-define-package
423 (read (current-buffer)) pkg-file)))
424 (setf (package-desc-dir pkg-desc) pkg-dir)
425 pkg-desc)))))
426
427 (defun package-load-all-descriptors ()
428 "Load descriptors for installed Emacs Lisp packages.
429 This looks for package subdirectories in `package-user-dir' and
430 `package-directory-list'. The variable `package-load-list'
431 controls which package subdirectories may be loaded.
432
433 In each valid package subdirectory, this function loads the
434 description file containing a call to `define-package', which
435 updates `package-alist'."
436 (dolist (dir (cons package-user-dir package-directory-list))
437 (when (file-directory-p dir)
438 (dolist (subdir (directory-files dir))
439 (let ((pkg-dir (expand-file-name subdir dir)))
440 (when (file-directory-p pkg-dir)
441 (package-load-descriptor pkg-dir)))))))
442
443 (defun package-disabled-p (pkg-name version)
444 "Return whether PKG-NAME at VERSION can be activated.
445 The decision is made according to `package-load-list'.
446 Return nil if the package can be activated.
447 Return t if the package is completely disabled.
448 Return the max version (as a string) if the package is held at a lower version."
449 (let ((force (assq pkg-name package-load-list)))
450 (cond ((null force) (not (memq 'all package-load-list)))
451 ((null (setq force (cadr force))) t) ; disabled
452 ((eq force t) nil)
453 ((stringp force) ; held
454 (unless (version-list-= version (version-to-list force))
455 force))
456 (t (error "Invalid element in `package-load-list'")))))
457
458 (defun package-activate-1 (pkg-desc)
459 (let* ((name (package-desc-name pkg-desc))
460 (pkg-dir (package-desc-dir pkg-desc))
461 (pkg-dir-dir (file-name-as-directory pkg-dir)))
462 (unless pkg-dir
463 (error "Internal error: unable to find directory for `%s'"
464 (package-desc-full-name pkg-desc)))
465 ;; Add to load path, add autoloads, and activate the package.
466 (let ((old-lp load-path))
467 (with-demoted-errors
468 (load (expand-file-name (format "%s-autoloads" name) pkg-dir) nil t))
469 (when (and (eq old-lp load-path)
470 (not (or (member pkg-dir load-path)
471 (member pkg-dir-dir load-path))))
472 ;; Old packages don't add themselves to the `load-path', so we have to
473 ;; do it ourselves.
474 (push pkg-dir load-path)))
475 ;; Add info node.
476 (when (file-exists-p (expand-file-name "dir" pkg-dir))
477 ;; FIXME: not the friendliest, but simple.
478 (require 'info)
479 (info-initialize)
480 (push pkg-dir Info-directory-list))
481 (push name package-activated-list)
482 ;; Don't return nil.
483 t))
484
485 (defun package-built-in-p (package &optional min-version)
486 "Return true if PACKAGE is built-in to Emacs.
487 Optional arg MIN-VERSION, if non-nil, should be a version list
488 specifying the minimum acceptable version."
489 (let ((bi (assq package package--builtin-versions)))
490 (cond
491 (bi (version-list-<= min-version (cdr bi)))
492 (min-version nil)
493 (t
494 (require 'finder-inf nil t) ; For `package--builtins'.
495 (assq package package--builtins)))))
496
497 (defun package--from-builtin (bi-desc)
498 (package-desc-create :name (pop bi-desc)
499 :version (package--bi-desc-version bi-desc)
500 :summary (package--bi-desc-summary bi-desc)
501 :dir 'builtin))
502
503 ;; This function goes ahead and activates a newer version of a package
504 ;; if an older one was already activated. This is not ideal; we'd at
505 ;; least need to check to see if the package has actually been loaded,
506 ;; and not merely activated.
507 (defun package-activate (package &optional force)
508 "Activate package PACKAGE.
509 If FORCE is true, (re-)activate it if it's already activated."
510 (let ((pkg-descs (cdr (assq package package-alist))))
511 ;; Check if PACKAGE is available in `package-alist'.
512 (while
513 (when pkg-descs
514 (let ((available-version (package-desc-version (car pkg-descs))))
515 (or (package-disabled-p package available-version)
516 ;; Prefer a builtin package.
517 (package-built-in-p package available-version))))
518 (setq pkg-descs (cdr pkg-descs)))
519 (cond
520 ;; If no such package is found, maybe it's built-in.
521 ((null pkg-descs)
522 (package-built-in-p package))
523 ;; If the package is already activated, just return t.
524 ((and (memq package package-activated-list) (not force))
525 t)
526 ;; Otherwise, proceed with activation.
527 (t
528 (let* ((pkg-vec (car pkg-descs))
529 (fail (catch 'dep-failure
530 ;; Activate its dependencies recursively.
531 (dolist (req (package-desc-reqs pkg-vec))
532 (unless (package-activate (car req) (cadr req))
533 (throw 'dep-failure req))))))
534 (if fail
535 (warn "Unable to activate package `%s'.
536 Required package `%s-%s' is unavailable"
537 package (car fail) (package-version-join (cadr fail)))
538 ;; If all goes well, activate the package itself.
539 (package-activate-1 pkg-vec)))))))
540
541 (defun define-package (_name-string _version-string
542 &optional _docstring _requirements
543 &rest _extra-properties)
544 "Define a new package.
545 NAME-STRING is the name of the package, as a string.
546 VERSION-STRING is the version of the package, as a string.
547 DOCSTRING is a short description of the package, a string.
548 REQUIREMENTS is a list of dependencies on other packages.
549 Each requirement is of the form (OTHER-PACKAGE OTHER-VERSION),
550 where OTHER-VERSION is a string.
551
552 EXTRA-PROPERTIES is currently unused."
553 ;; FIXME: Placeholder! Should we keep it?
554 (error "Don't call me!"))
555
556 (defun package-process-define-package (exp origin)
557 (unless (eq (car-safe exp) 'define-package)
558 (error "Can't find define-package in %s" origin))
559 (let* ((new-pkg-desc (apply #'package-desc-from-define (cdr exp)))
560 (name (package-desc-name new-pkg-desc))
561 (version (package-desc-version new-pkg-desc))
562 (old-pkgs (assq name package-alist)))
563 (if (null old-pkgs)
564 ;; If there's no old package, just add this to `package-alist'.
565 (push (list name new-pkg-desc) package-alist)
566 ;; If there is, insert the new package at the right place in the list.
567 (while
568 (if (and (cdr old-pkgs)
569 (version-list-< version
570 (package-desc-version (cadr old-pkgs))))
571 (setq old-pkgs (cdr old-pkgs))
572 (push new-pkg-desc (cdr old-pkgs))
573 nil)))
574 new-pkg-desc))
575
576 ;; From Emacs 22, but changed so it adds to load-path.
577 (defun package-autoload-ensure-default-file (file)
578 "Make sure that the autoload file FILE exists and if not create it."
579 (unless (file-exists-p file)
580 (write-region
581 (concat ";;; " (file-name-nondirectory file)
582 " --- automatically extracted autoloads\n"
583 ";;\n"
584 ";;; Code:\n"
585 "(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))\n"
586 "\f\n;; Local Variables:\n"
587 ";; version-control: never\n"
588 ";; no-byte-compile: t\n"
589 ";; no-update-autoloads: t\n"
590 ";; End:\n"
591 ";;; " (file-name-nondirectory file)
592 " ends here\n")
593 nil file))
594 file)
595
596 (defvar generated-autoload-file)
597 (defvar version-control)
598
599 (defun package-generate-autoloads (name pkg-dir)
600 (require 'autoload) ;Load before we let-bind generated-autoload-file!
601 (let* ((auto-name (format "%s-autoloads.el" name))
602 ;;(ignore-name (concat name "-pkg.el"))
603 (generated-autoload-file (expand-file-name auto-name pkg-dir))
604 (version-control 'never))
605 (package-autoload-ensure-default-file generated-autoload-file)
606 (update-directory-autoloads pkg-dir)
607 (let ((buf (find-buffer-visiting generated-autoload-file)))
608 (when buf (kill-buffer buf)))
609 auto-name))
610
611 (defvar tar-parse-info)
612 (declare-function tar-untar-buffer "tar-mode" ())
613 (declare-function tar-header-name "tar-mode" (tar-header) t)
614 (declare-function tar-header-link-type "tar-mode" (tar-header) t)
615
616 (defun package-untar-buffer (dir)
617 "Untar the current buffer.
618 This uses `tar-untar-buffer' from Tar mode. All files should
619 untar into a directory named DIR; otherwise, signal an error."
620 (require 'tar-mode)
621 (tar-mode)
622 ;; Make sure everything extracts into DIR.
623 (let ((regexp (concat "\\`" (regexp-quote (expand-file-name dir)) "/"))
624 (case-fold-search (memq system-type '(windows-nt ms-dos cygwin))))
625 (dolist (tar-data tar-parse-info)
626 (let ((name (expand-file-name (tar-header-name tar-data))))
627 (or (string-match regexp name)
628 ;; Tarballs created by some utilities don't list
629 ;; directories with a trailing slash (Bug#13136).
630 (and (string-equal dir name)
631 (eq (tar-header-link-type tar-data) 5))
632 (error "Package does not untar cleanly into directory %s/" dir)))))
633 (tar-untar-buffer))
634
635 (defun package-generate-description-file (pkg-desc pkg-dir)
636 "Create the foo-pkg.el file for single-file packages."
637 (let* ((name (package-desc-name pkg-desc))
638 (pkg-file (expand-file-name (package--description-file pkg-dir)
639 pkg-dir)))
640 (let ((print-level nil)
641 (print-quoted t)
642 (print-length nil))
643 (write-region
644 (concat
645 (prin1-to-string
646 (list 'define-package
647 (symbol-name name)
648 (package-version-join (package-desc-version pkg-desc))
649 (package-desc-summary pkg-desc)
650 (let ((requires (package-desc-reqs pkg-desc)))
651 (list 'quote
652 ;; Turn version lists into string form.
653 (mapcar
654 (lambda (elt)
655 (list (car elt)
656 (package-version-join (cadr elt))))
657 requires)))))
658 "\n")
659 nil
660 pkg-file))))
661
662 (defun package-unpack (pkg-desc)
663 "Install the contents of the current buffer as a package."
664 (let* ((name (package-desc-name pkg-desc))
665 (dirname (package-desc-full-name pkg-desc))
666 (pkg-dir (expand-file-name dirname package-user-dir)))
667 (pcase (package-desc-kind pkg-desc)
668 (`tar
669 (make-directory package-user-dir t)
670 ;; FIXME: should we delete PKG-DIR if it exists?
671 (let* ((default-directory (file-name-as-directory package-user-dir)))
672 (package-untar-buffer dirname)))
673 (`single
674 (let ((el-file (expand-file-name (format "%s.el" name) pkg-dir)))
675 (make-directory pkg-dir t)
676 (package--write-file-no-coding el-file)))
677 (kind (error "Unknown package kind: %S" kind)))
678 (package--make-autoloads-and-stuff pkg-desc pkg-dir)
679 ;; Update package-alist.
680 (let ((new-desc (package-load-descriptor pkg-dir)))
681 ;; FIXME: Check that `new-desc' matches `desc'!
682 ;; FIXME: Compilation should be done as a separate, optional, step.
683 ;; E.g. for multi-package installs, we should first install all packages
684 ;; and then compile them.
685 (package--compile new-desc))
686 ;; Try to activate it.
687 (package-activate name 'force)
688 pkg-dir))
689
690 (defun package--make-autoloads-and-stuff (pkg-desc pkg-dir)
691 "Generate autoloads, description file, etc.. for PKG-DESC installed at PKG-DIR."
692 (package-generate-autoloads (package-desc-name pkg-desc) pkg-dir)
693 (let ((desc-file (package--description-file pkg-dir)))
694 (unless (file-exists-p desc-file)
695 (package-generate-description-file pkg-desc pkg-dir)))
696 ;; FIXME: Create foo.info and dir file from foo.texi?
697 )
698
699 (defun package--compile (pkg-desc)
700 "Byte-compile installed package PKG-DESC."
701 (package-activate-1 pkg-desc)
702 (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))
703
704 (defun package--write-file-no-coding (file-name)
705 (let ((buffer-file-coding-system 'no-conversion))
706 (write-region (point-min) (point-max) file-name)))
707
708 (defmacro package--with-work-buffer (location file &rest body)
709 "Run BODY in a buffer containing the contents of FILE at LOCATION.
710 LOCATION is the base location of a package archive, and should be
711 one of the URLs (or file names) specified in `package-archives'.
712 FILE is the name of a file relative to that base location.
713
714 This macro retrieves FILE from LOCATION into a temporary buffer,
715 and evaluates BODY while that buffer is current. This work
716 buffer is killed afterwards. Return the last value in BODY."
717 (declare (indent 2) (debug t))
718 `(let* ((http (string-match "\\`https?:" ,location))
719 (buffer
720 (if http
721 (url-retrieve-synchronously (concat ,location ,file))
722 (generate-new-buffer "*package work buffer*"))))
723 (prog1
724 (with-current-buffer buffer
725 (if http
726 (progn (package-handle-response)
727 (re-search-forward "^$" nil 'move)
728 (forward-char)
729 (delete-region (point-min) (point)))
730 (unless (file-name-absolute-p ,location)
731 (error "Archive location %s is not an absolute file name"
732 ,location))
733 (insert-file-contents (expand-file-name ,file ,location)))
734 ,@body)
735 (kill-buffer buffer))))
736
737 (defun package-handle-response ()
738 "Handle the response from a `url-retrieve-synchronously' call.
739 Parse the HTTP response and throw if an error occurred.
740 The url package seems to require extra processing for this.
741 This should be called in a `save-excursion', in the download buffer.
742 It will move point to somewhere in the headers."
743 ;; We assume HTTP here.
744 (require 'url-http)
745 (let ((response (url-http-parse-response)))
746 (when (or (< response 200) (>= response 300))
747 (error "Error during download request:%s"
748 (buffer-substring-no-properties (point) (line-end-position))))))
749
750 (defun package-install-from-archive (pkg-desc)
751 "Download and install a tar package."
752 (let ((location (package-archive-base pkg-desc))
753 (file (concat (package-desc-full-name pkg-desc)
754 (package-desc-suffix pkg-desc))))
755 (package--with-work-buffer location file
756 (package-unpack pkg-desc))))
757
758 (defvar package--initialized nil)
759
760 (defun package-installed-p (package &optional min-version)
761 "Return true if PACKAGE, of MIN-VERSION or newer, is installed.
762 MIN-VERSION should be a version list."
763 (unless package--initialized (error "package.el is not yet initialized!"))
764 (or
765 (let ((pkg-descs (cdr (assq package package-alist))))
766 (and pkg-descs
767 (version-list-<= min-version
768 (package-desc-version (car pkg-descs)))))
769 ;; Also check built-in packages.
770 (package-built-in-p package min-version)))
771
772 (defun package-compute-transaction (packages requirements)
773 "Return a list of packages to be installed, including PACKAGES.
774 PACKAGES should be a list of `package-desc'.
775
776 REQUIREMENTS should be a list of additional requirements; each
777 element in this list should have the form (PACKAGE VERSION-LIST),
778 where PACKAGE is a package name and VERSION-LIST is the required
779 version of that package.
780
781 This function recursively computes the requirements of the
782 packages in REQUIREMENTS, and returns a list of all the packages
783 that must be installed. Packages that are already installed are
784 not included in this list."
785 ;; FIXME: We really should use backtracking to explore the whole
786 ;; search space (e.g. if foo require bar-1.3, and bar-1.4 requires toto-1.1
787 ;; whereas bar-1.3 requires toto-1.0 and the user has put a hold on toto-1.0:
788 ;; the current code might fail to see that it could install foo by using the
789 ;; older bar-1.3).
790 (dolist (elt requirements)
791 (let* ((next-pkg (car elt))
792 (next-version (cadr elt))
793 (already ()))
794 (dolist (pkg packages)
795 (if (eq next-pkg (package-desc-name pkg))
796 (setq already pkg)))
797 (cond
798 (already
799 (if (version-list-< next-version (package-desc-version already))
800 ;; Move to front, so it gets installed early enough (bug#14082).
801 (setq packages (cons already (delq already packages)))
802 (error "Need package `%s-%s', but only %s is available"
803 next-pkg (package-version-join next-version)
804 (package-version-join (package-desc-version already)))))
805
806 ((package-installed-p next-pkg next-version) nil)
807
808 (t
809 ;; A package is required, but not installed. It might also be
810 ;; blocked via `package-load-list'.
811 (let ((pkg-descs (cdr (assq next-pkg package-archive-contents)))
812 (found nil)
813 (problem nil))
814 (while (and pkg-descs (not found))
815 (let* ((pkg-desc (pop pkg-descs))
816 (version (package-desc-version pkg-desc))
817 (disabled (package-disabled-p next-pkg version)))
818 (cond
819 ((version-list-< version next-version)
820 (error
821 "Need package `%s-%s', but only %s is available"
822 next-pkg (package-version-join next-version)
823 (package-version-join version)))
824 (disabled
825 (unless problem
826 (setq problem
827 (if (stringp disabled)
828 (format "Package `%s' held at version %s, \
829 but version %s required"
830 next-pkg disabled
831 (package-version-join next-version))
832 (format "Required package '%s' is disabled"
833 next-pkg)))))
834 (t (setq found pkg-desc)))))
835 (unless found
836 (if problem
837 (error problem)
838 (error "Package `%s-%s' is unavailable"
839 next-pkg (package-version-join next-version))))
840 (setq packages
841 (package-compute-transaction (cons found packages)
842 (package-desc-reqs found))))))))
843 packages)
844
845 (defun package-read-from-string (str)
846 "Read a Lisp expression from STR.
847 Signal an error if the entire string was not used."
848 (let* ((read-data (read-from-string str))
849 (more-left
850 (condition-case nil
851 ;; The call to `ignore' suppresses a compiler warning.
852 (progn (ignore (read-from-string
853 (substring str (cdr read-data))))
854 t)
855 (end-of-file nil))))
856 (if more-left
857 (error "Can't read whole string")
858 (car read-data))))
859
860 (defun package--read-archive-file (file)
861 "Re-read archive file FILE, if it exists.
862 Will return the data from the file, or nil if the file does not exist.
863 Will throw an error if the archive version is too new."
864 (let ((filename (expand-file-name file package-user-dir)))
865 (when (file-exists-p filename)
866 (with-temp-buffer
867 (insert-file-contents-literally filename)
868 (let ((contents (read (current-buffer))))
869 (if (> (car contents) package-archive-version)
870 (error "Package archive version %d is higher than %d"
871 (car contents) package-archive-version))
872 (cdr contents))))))
873
874 (defun package-read-all-archive-contents ()
875 "Re-read `archive-contents', if it exists.
876 If successful, set `package-archive-contents'."
877 (setq package-archive-contents nil)
878 (dolist (archive package-archives)
879 (package-read-archive-contents (car archive))))
880
881 (defun package-read-archive-contents (archive)
882 "Re-read archive contents for ARCHIVE.
883 If successful, set the variable `package-archive-contents'.
884 If the archive version is too new, signal an error."
885 ;; Version 1 of 'archive-contents' is identical to our internal
886 ;; representation.
887 (let* ((contents-file (format "archives/%s/archive-contents" archive))
888 (contents (package--read-archive-file contents-file)))
889 (when contents
890 (dolist (package contents)
891 (package--add-to-archive-contents package archive)))))
892
893 ;; Package descriptor objects used inside the "archive-contents" file.
894 ;; Changing this defstruct implies changing the format of the
895 ;; "archive-contents" files.
896 (cl-defstruct (package--ac-desc
897 (:constructor package-make-ac-desc (version reqs summary kind))
898 (:copier nil)
899 (:type vector))
900 version reqs summary kind)
901
902 (defun package--add-to-archive-contents (package archive)
903 "Add the PACKAGE from the given ARCHIVE if necessary.
904 PACKAGE should have the form (NAME . PACKAGE--AC-DESC).
905 Also, add the originating archive to the `package-desc' structure."
906 (let* ((name (car package))
907 (version (package--ac-desc-version (cdr package)))
908 (pkg-desc
909 (package-desc-create
910 :name name
911 :version version
912 :reqs (package--ac-desc-reqs (cdr package))
913 :summary (package--ac-desc-summary (cdr package))
914 :kind (package--ac-desc-kind (cdr package))
915 :archive archive))
916 (existing-packages (assq name package-archive-contents))
917 (pinned-to-archive (assoc name package-pinned-packages)))
918 (cond
919 ;; Skip entirely if pinned to another archive or already installed.
920 ((or (and pinned-to-archive
921 (not (equal (cdr pinned-to-archive) archive)))
922 (let ((bi (assq name package--builtin-versions)))
923 (and bi (version-list-= version (cdr bi))))
924 (let ((ins (cdr (assq name package-alist))))
925 (and ins (version-list-= version
926 (package-desc-version (car ins))))))
927 nil)
928 ((not existing-packages)
929 (push (list name pkg-desc) package-archive-contents))
930 (t
931 (while
932 (if (and (cdr existing-packages)
933 (version-list-<
934 version (package-desc-version (cadr existing-packages))))
935 (setq existing-packages (cdr existing-packages))
936 (push pkg-desc (cdr existing-packages))
937 nil))))))
938
939 (defun package-download-transaction (packages)
940 "Download and install all the packages in PACKAGES.
941 PACKAGES should be a list of package-desc.
942 This function assumes that all package requirements in
943 PACKAGES are satisfied, i.e. that PACKAGES is computed
944 using `package-compute-transaction'."
945 (mapc #'package-install-from-archive packages))
946
947 ;;;###autoload
948 (defun package-install (pkg)
949 "Install the package PKG.
950 PKG can be a package-desc or the package name of one the available packages
951 in an archive in `package-archives'. Interactively, prompt for its name."
952 (interactive
953 (progn
954 ;; Initialize the package system to get the list of package
955 ;; symbols for completion.
956 (unless package--initialized
957 (package-initialize t))
958 (unless package-archive-contents
959 (package-refresh-contents))
960 (list (intern (completing-read
961 "Install package: "
962 (mapcar (lambda (elt) (symbol-name (car elt)))
963 package-archive-contents)
964 nil t)))))
965 (package-download-transaction
966 (if (package-desc-p pkg)
967 (package-compute-transaction (list pkg)
968 (package-desc-reqs pkg))
969 (package-compute-transaction ()
970 (list (list pkg))))))
971
972 (defun package-strip-rcs-id (str)
973 "Strip RCS version ID from the version string STR.
974 If the result looks like a dotted numeric version, return it.
975 Otherwise return nil."
976 (when str
977 (when (string-match "\\`[ \t]*[$]Revision:[ \t]+" str)
978 (setq str (substring str (match-end 0))))
979 (condition-case nil
980 (if (version-to-list str)
981 str)
982 (error nil))))
983
984 (defun package-buffer-info ()
985 "Return a `package-desc' describing the package in the current buffer.
986
987 If the buffer does not contain a conforming package, signal an
988 error. If there is a package, narrow the buffer to the file's
989 boundaries."
990 (goto-char (point-min))
991 (unless (re-search-forward "^;;; \\([^ ]*\\)\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" nil t)
992 (error "Package lacks a file header"))
993 (let ((file-name (match-string-no-properties 1))
994 (desc (match-string-no-properties 2))
995 (start (line-beginning-position)))
996 (unless (search-forward (concat ";;; " file-name ".el ends here"))
997 (error "Package lacks a terminating comment"))
998 ;; Try to include a trailing newline.
999 (forward-line)
1000 (narrow-to-region start (point))
1001 (require 'lisp-mnt)
1002 ;; Use some headers we've invented to drive the process.
1003 (let* ((requires-str (lm-header "package-requires"))
1004 ;; Prefer Package-Version; if defined, the package author
1005 ;; probably wants us to use it. Otherwise try Version.
1006 (pkg-version
1007 (or (package-strip-rcs-id (lm-header "package-version"))
1008 (package-strip-rcs-id (lm-header "version")))))
1009 (unless pkg-version
1010 (error
1011 "Package lacks a \"Version\" or \"Package-Version\" header"))
1012 (package-desc-from-define
1013 file-name pkg-version desc
1014 (if requires-str (package-read-from-string requires-str))
1015 :kind 'single))))
1016
1017 (declare-function tar-get-file-descriptor "tar-mode" (file))
1018 (declare-function tar--extract "tar-mode" (descriptor))
1019
1020 (defun package-tar-file-info ()
1021 "Find package information for a tar file.
1022 The return result is a `package-desc'."
1023 (cl-assert (derived-mode-p 'tar-mode))
1024 (let* ((dir-name (file-name-directory
1025 (tar-header-name (car tar-parse-info))))
1026 (desc-file (package--description-file dir-name))
1027 (tar-desc (tar-get-file-descriptor (concat dir-name desc-file))))
1028 (unless tar-desc
1029 (error "No package descriptor file found"))
1030 (with-current-buffer (tar--extract tar-desc)
1031 (goto-char (point-min))
1032 (unwind-protect
1033 (let* ((pkg-def-parsed (read (current-buffer)))
1034 (pkg-desc
1035 (if (not (eq (car pkg-def-parsed) 'define-package))
1036 (error "Can't find define-package in %s"
1037 (tar-header-name tar-desc))
1038 (apply #'package-desc-from-define
1039 (append (cdr pkg-def-parsed))))))
1040 (setf (package-desc-kind pkg-desc) 'tar)
1041 pkg-desc)
1042 (kill-buffer (current-buffer))))))
1043
1044
1045 ;;;###autoload
1046 (defun package-install-from-buffer ()
1047 "Install a package from the current buffer.
1048 The current buffer is assumed to be a single .el or .tar file that follows the
1049 packaging guidelines; see info node `(elisp)Packaging'.
1050 Downloads and installs required packages as needed."
1051 (interactive)
1052 (let ((pkg-desc (if (derived-mode-p 'tar-mode)
1053 (package-tar-file-info)
1054 (package-buffer-info))))
1055 ;; Download and install the dependencies.
1056 (let* ((requires (package-desc-reqs pkg-desc))
1057 (transaction (package-compute-transaction nil requires)))
1058 (package-download-transaction transaction))
1059 ;; Install the package itself.
1060 (package-unpack pkg-desc)
1061 pkg-desc))
1062
1063 ;;;###autoload
1064 (defun package-install-file (file)
1065 "Install a package from a file.
1066 The file can either be a tar file or an Emacs Lisp file."
1067 (interactive "fPackage file name: ")
1068 (with-temp-buffer
1069 (insert-file-contents-literally file)
1070 (when (string-match "\\.tar\\'" file) (tar-mode))
1071 (package-install-from-buffer)))
1072
1073 (defun package-delete (pkg-desc)
1074 (let ((dir (package-desc-dir pkg-desc)))
1075 (if (not (string-prefix-p (file-name-as-directory
1076 (expand-file-name package-user-dir))
1077 (expand-file-name dir)))
1078 ;; Don't delete "system" packages.
1079 (error "Package `%s' is a system package, not deleting"
1080 (package-desc-full-name pkg-desc))
1081 (delete-directory dir t t)
1082 ;; Update package-alist.
1083 (let* ((name (package-desc-name pkg-desc)))
1084 (delete pkg-desc (assq name package-alist)))
1085 (message "Package `%s' deleted." (package-desc-full-name pkg-desc)))))
1086
1087 (defun package-archive-base (desc)
1088 "Return the archive containing the package NAME."
1089 (cdr (assoc (package-desc-archive desc) package-archives)))
1090
1091 (defun package--download-one-archive (archive file)
1092 "Retrieve an archive file FILE from ARCHIVE, and cache it.
1093 ARCHIVE should be a cons cell of the form (NAME . LOCATION),
1094 similar to an entry in `package-alist'. Save the cached copy to
1095 \"archives/NAME/archive-contents\" in `package-user-dir'."
1096 (let* ((dir (expand-file-name (format "archives/%s" (car archive))
1097 package-user-dir)))
1098 (package--with-work-buffer (cdr archive) file
1099 ;; Read the retrieved buffer to make sure it is valid (e.g. it
1100 ;; may fetch a URL redirect page).
1101 (when (listp (read buffer))
1102 (make-directory dir t)
1103 (setq buffer-file-name (expand-file-name file dir))
1104 (let ((version-control 'never))
1105 (save-buffer))))))
1106
1107 ;;;###autoload
1108 (defun package-refresh-contents ()
1109 "Download the ELPA archive description if needed.
1110 This informs Emacs about the latest versions of all packages, and
1111 makes them available for download."
1112 (interactive)
1113 ;; FIXME: Do it asynchronously.
1114 (unless (file-exists-p package-user-dir)
1115 (make-directory package-user-dir t))
1116 (dolist (archive package-archives)
1117 (condition-case-unless-debug nil
1118 (package--download-one-archive archive "archive-contents")
1119 (error (message "Failed to download `%s' archive."
1120 (car archive)))))
1121 (package-read-all-archive-contents))
1122
1123 ;;;###autoload
1124 (defun package-initialize (&optional no-activate)
1125 "Load Emacs Lisp packages, and activate them.
1126 The variable `package-load-list' controls which packages to load.
1127 If optional arg NO-ACTIVATE is non-nil, don't activate packages."
1128 (interactive)
1129 (setq package-alist nil)
1130 (package-load-all-descriptors)
1131 (package-read-all-archive-contents)
1132 (unless no-activate
1133 (dolist (elt package-alist)
1134 (package-activate (car elt))))
1135 (setq package--initialized t))
1136
1137 \f
1138 ;;;; Package description buffer.
1139
1140 ;;;###autoload
1141 (defun describe-package (package)
1142 "Display the full documentation of PACKAGE (a symbol)."
1143 (interactive
1144 (let* ((guess (function-called-at-point)))
1145 (require 'finder-inf nil t)
1146 ;; Load the package list if necessary (but don't activate them).
1147 (unless package--initialized
1148 (package-initialize t))
1149 (let ((packages (append (mapcar 'car package-alist)
1150 (mapcar 'car package-archive-contents)
1151 (mapcar 'car package--builtins))))
1152 (unless (memq guess packages)
1153 (setq guess nil))
1154 (setq packages (mapcar 'symbol-name packages))
1155 (let ((val
1156 (completing-read (if guess
1157 (format "Describe package (default %s): "
1158 guess)
1159 "Describe package: ")
1160 packages nil t nil nil guess)))
1161 (list (intern val))))))
1162 (if (not (or (package-desc-p package) (and package (symbolp package))))
1163 (message "No package specified")
1164 (help-setup-xref (list #'describe-package package)
1165 (called-interactively-p 'interactive))
1166 (with-help-window (help-buffer)
1167 (with-current-buffer standard-output
1168 (describe-package-1 package)))))
1169
1170 (defun describe-package-1 (pkg)
1171 (require 'lisp-mnt)
1172 (let* ((desc (or
1173 (if (package-desc-p pkg) pkg)
1174 (cadr (assq pkg package-alist))
1175 (let ((built-in (assq pkg package--builtins)))
1176 (if built-in
1177 (package--from-builtin built-in)
1178 (cadr (assq pkg package-archive-contents))))))
1179 (name (if desc (package-desc-name desc) pkg))
1180 (pkg-dir (if desc (package-desc-dir desc)))
1181 (reqs (if desc (package-desc-reqs desc)))
1182 (version (if desc (package-desc-version desc)))
1183 (archive (if desc (package-desc-archive desc)))
1184 (built-in (eq pkg-dir 'builtin))
1185 (installable (and archive (not built-in)))
1186 (status (if desc (package-desc-status desc) "orphan")))
1187 (prin1 name)
1188 (princ " is ")
1189 (princ (if (memq (aref status 0) '(?a ?e ?i ?o ?u)) "an " "a "))
1190 (princ status)
1191 (princ " package.\n\n")
1192
1193 (insert " " (propertize "Status" 'font-lock-face 'bold) ": ")
1194 (cond (built-in
1195 (insert (propertize (capitalize status)
1196 'font-lock-face 'font-lock-builtin-face)
1197 "."))
1198 (pkg-dir
1199 (insert (propertize (capitalize status) ;FIXME: Why comment-face?
1200 'font-lock-face 'font-lock-comment-face))
1201 (insert " in `")
1202 ;; Todo: Add button for uninstalling.
1203 (help-insert-xref-button (abbreviate-file-name
1204 (file-name-as-directory pkg-dir))
1205 'help-package-def pkg-dir)
1206 (if (and (package-built-in-p name)
1207 (not (package-built-in-p name version)))
1208 (insert "',\n shadowing a "
1209 (propertize "built-in package"
1210 'font-lock-face 'font-lock-builtin-face)
1211 ".")
1212 (insert "'.")))
1213 (installable
1214 (insert (capitalize status))
1215 (insert " from " (format "%s" archive))
1216 (insert " -- ")
1217 (let ((button-text (if (display-graphic-p) "Install" "[Install]"))
1218 (button-face (if (display-graphic-p)
1219 '(:box (:line-width 2 :color "dark grey")
1220 :background "light grey"
1221 :foreground "black")
1222 'link)))
1223 (insert-text-button button-text 'face button-face 'follow-link t
1224 'package-desc desc
1225 'action 'package-install-button-action)))
1226 (t (insert (capitalize status) ".")))
1227 (insert "\n")
1228 (and version
1229 (insert " "
1230 (propertize "Version" 'font-lock-face 'bold) ": "
1231 (package-version-join version) "\n"))
1232
1233 (setq reqs (if desc (package-desc-reqs desc)))
1234 (when reqs
1235 (insert " " (propertize "Requires" 'font-lock-face 'bold) ": ")
1236 (let ((first t)
1237 name vers text)
1238 (dolist (req reqs)
1239 (setq name (car req)
1240 vers (cadr req)
1241 text (format "%s-%s" (symbol-name name)
1242 (package-version-join vers)))
1243 (cond (first (setq first nil))
1244 ((>= (+ 2 (current-column) (length text))
1245 (window-width))
1246 (insert ",\n "))
1247 (t (insert ", ")))
1248 (help-insert-xref-button text 'help-package name))
1249 (insert "\n")))
1250 (insert " " (propertize "Summary" 'font-lock-face 'bold)
1251 ": " (if desc (package-desc-summary desc)) "\n")
1252
1253 (let* ((all-pkgs (append (cdr (assq name package-alist))
1254 (cdr (assq name package-archive-contents))
1255 (let ((bi (assq name package--builtins)))
1256 (if bi (list (package--from-builtin bi))))))
1257 (other-pkgs (delete desc all-pkgs)))
1258 (when other-pkgs
1259 (insert " " (propertize "Other versions" 'font-lock-face 'bold) ": "
1260 (mapconcat
1261 (lambda (opkg)
1262 (let* ((ov (package-desc-version opkg))
1263 (dir (package-desc-dir opkg))
1264 (from (or (package-desc-archive opkg)
1265 (if (stringp dir) "installed" dir))))
1266 (if (not ov) (format "%s" from)
1267 (format "%s (%s)"
1268 (make-text-button (package-version-join ov) nil
1269 'face 'link
1270 'follow-link t
1271 'action
1272 (lambda (_button)
1273 (describe-package opkg)))
1274 from))))
1275 other-pkgs ", ")
1276 ".\n")))
1277
1278 (insert "\n")
1279
1280 (if built-in
1281 ;; For built-in packages, insert the commentary.
1282 (let ((fn (locate-file (format "%s.el" name) load-path
1283 load-file-rep-suffixes))
1284 (opoint (point)))
1285 (insert (or (lm-commentary fn) ""))
1286 (save-excursion
1287 (goto-char opoint)
1288 (when (re-search-forward "^;;; Commentary:\n" nil t)
1289 (replace-match ""))
1290 (while (re-search-forward "^\\(;+ ?\\)" nil t)
1291 (replace-match ""))))
1292 (let ((readme (expand-file-name (format "%s-readme.txt" name)
1293 package-user-dir))
1294 readme-string)
1295 ;; For elpa packages, try downloading the commentary. If that
1296 ;; fails, try an existing readme file in `package-user-dir'.
1297 (cond ((condition-case nil
1298 (package--with-work-buffer
1299 (package-archive-base desc)
1300 (format "%s-readme.txt" name)
1301 (setq buffer-file-name
1302 (expand-file-name readme package-user-dir))
1303 (let ((version-control 'never))
1304 (save-buffer))
1305 (setq readme-string (buffer-string))
1306 t)
1307 (error nil))
1308 (insert readme-string))
1309 ((file-readable-p readme)
1310 (insert-file-contents readme)
1311 (goto-char (point-max))))))))
1312
1313 (defun package-install-button-action (button)
1314 (let ((pkg-desc (button-get button 'package-desc)))
1315 (when (y-or-n-p (format "Install package `%s'? "
1316 (package-desc-full-name pkg-desc)))
1317 (package-install pkg-desc)
1318 (revert-buffer nil t)
1319 (goto-char (point-min)))))
1320
1321 \f
1322 ;;;; Package menu mode.
1323
1324 (defvar package-menu-mode-map
1325 (let ((map (make-sparse-keymap))
1326 (menu-map (make-sparse-keymap "Package")))
1327 (set-keymap-parent map tabulated-list-mode-map)
1328 (define-key map "\C-m" 'package-menu-describe-package)
1329 (define-key map "u" 'package-menu-mark-unmark)
1330 (define-key map "\177" 'package-menu-backup-unmark)
1331 (define-key map "d" 'package-menu-mark-delete)
1332 (define-key map "i" 'package-menu-mark-install)
1333 (define-key map "U" 'package-menu-mark-upgrades)
1334 (define-key map "r" 'package-menu-refresh)
1335 (define-key map "~" 'package-menu-mark-obsolete-for-deletion)
1336 (define-key map "x" 'package-menu-execute)
1337 (define-key map "h" 'package-menu-quick-help)
1338 (define-key map "?" 'package-menu-describe-package)
1339 (define-key map [menu-bar package-menu] (cons "Package" menu-map))
1340 (define-key menu-map [mq]
1341 '(menu-item "Quit" quit-window
1342 :help "Quit package selection"))
1343 (define-key menu-map [s1] '("--"))
1344 (define-key menu-map [mn]
1345 '(menu-item "Next" next-line
1346 :help "Next Line"))
1347 (define-key menu-map [mp]
1348 '(menu-item "Previous" previous-line
1349 :help "Previous Line"))
1350 (define-key menu-map [s2] '("--"))
1351 (define-key menu-map [mu]
1352 '(menu-item "Unmark" package-menu-mark-unmark
1353 :help "Clear any marks on a package and move to the next line"))
1354 (define-key menu-map [munm]
1355 '(menu-item "Unmark Backwards" package-menu-backup-unmark
1356 :help "Back up one line and clear any marks on that package"))
1357 (define-key menu-map [md]
1358 '(menu-item "Mark for Deletion" package-menu-mark-delete
1359 :help "Mark a package for deletion and move to the next line"))
1360 (define-key menu-map [mi]
1361 '(menu-item "Mark for Install" package-menu-mark-install
1362 :help "Mark a package for installation and move to the next line"))
1363 (define-key menu-map [mupgrades]
1364 '(menu-item "Mark Upgradable Packages" package-menu-mark-upgrades
1365 :help "Mark packages that have a newer version for upgrading"))
1366 (define-key menu-map [s3] '("--"))
1367 (define-key menu-map [mg]
1368 '(menu-item "Update Package List" revert-buffer
1369 :help "Update the list of packages"))
1370 (define-key menu-map [mr]
1371 '(menu-item "Refresh Package List" package-menu-refresh
1372 :help "Download the ELPA archive"))
1373 (define-key menu-map [s4] '("--"))
1374 (define-key menu-map [mt]
1375 '(menu-item "Mark Obsolete Packages" package-menu-mark-obsolete-for-deletion
1376 :help "Mark all obsolete packages for deletion"))
1377 (define-key menu-map [mx]
1378 '(menu-item "Execute Actions" package-menu-execute
1379 :help "Perform all the marked actions"))
1380 (define-key menu-map [s5] '("--"))
1381 (define-key menu-map [mh]
1382 '(menu-item "Help" package-menu-quick-help
1383 :help "Show short key binding help for package-menu-mode"))
1384 (define-key menu-map [mc]
1385 '(menu-item "View Commentary" package-menu-view-commentary
1386 :help "Display information about this package"))
1387 map)
1388 "Local keymap for `package-menu-mode' buffers.")
1389
1390 (defvar package-menu--new-package-list nil
1391 "List of newly-available packages since `list-packages' was last called.")
1392
1393 (define-derived-mode package-menu-mode tabulated-list-mode "Package Menu"
1394 "Major mode for browsing a list of packages.
1395 Letters do not insert themselves; instead, they are commands.
1396 \\<package-menu-mode-map>
1397 \\{package-menu-mode-map}"
1398 (setq tabulated-list-format [("Package" 18 package-menu--name-predicate)
1399 ("Version" 12 nil)
1400 ("Status" 10 package-menu--status-predicate)
1401 ("Description" 0 nil)])
1402 (setq tabulated-list-padding 2)
1403 (setq tabulated-list-sort-key (cons "Status" nil))
1404 (add-hook 'tabulated-list-revert-hook 'package-menu--refresh nil t)
1405 (tabulated-list-init-header))
1406
1407 (defmacro package--push (pkg-desc status listname)
1408 "Convenience macro for `package-menu--generate'.
1409 If the alist stored in the symbol LISTNAME lacks an entry for a
1410 package PKG-DESC, add one. The alist is keyed with PKG-DESC."
1411 `(unless (assoc ,pkg-desc ,listname)
1412 ;; FIXME: Should we move status into pkg-desc?
1413 (push (cons ,pkg-desc ,status) ,listname)))
1414
1415 (defvar package-list-unversioned nil
1416 "If non-nil include packages that don't have a version in `list-package'.")
1417
1418 (defun package-desc-status (pkg-desc)
1419 (let* ((name (package-desc-name pkg-desc))
1420 (dir (package-desc-dir pkg-desc))
1421 (lle (assq name package-load-list))
1422 (held (cadr lle))
1423 (version (package-desc-version pkg-desc)))
1424 (cond
1425 ((eq dir 'builtin) "built-in")
1426 ((and lle (null held)) "disabled")
1427 ((stringp held)
1428 (let ((hv (if (stringp held) (version-to-list held))))
1429 (cond
1430 ((version-list-= version hv) "held")
1431 ((version-list-< version hv) "obsolete")
1432 (t "disabled"))))
1433 ((package-built-in-p name version) "obsolete")
1434 (dir ;One of the installed packages.
1435 (cond
1436 ((not (file-exists-p (package-desc-dir pkg-desc))) "deleted")
1437 ((eq pkg-desc (cadr (assq name package-alist))) "installed")
1438 (t "obsolete")))
1439 (t
1440 (let* ((ins (cadr (assq name package-alist)))
1441 (ins-v (if ins (package-desc-version ins))))
1442 (cond
1443 ((or (null ins) (version-list-< ins-v version))
1444 (if (memq name package-menu--new-package-list)
1445 "new" "available"))
1446 ((version-list-< version ins-v) "obsolete")
1447 ((version-list-= version ins-v) "installed")))))))
1448
1449 (defun package-menu--refresh (&optional packages)
1450 "Re-populate the `tabulated-list-entries'.
1451 PACKAGES should be nil or t, which means to display all known packages."
1452 ;; Construct list of (PKG-DESC . STATUS).
1453 (unless packages (setq packages t))
1454 (let (info-list name)
1455 ;; Installed packages:
1456 (dolist (elt package-alist)
1457 (setq name (car elt))
1458 (when (or (eq packages t) (memq name packages))
1459 (dolist (pkg (cdr elt))
1460 (package--push pkg (package-desc-status pkg) info-list))))
1461
1462 ;; Built-in packages:
1463 (dolist (elt package--builtins)
1464 (setq name (car elt))
1465 (when (and (not (eq name 'emacs)) ; Hide the `emacs' package.
1466 (or package-list-unversioned
1467 (package--bi-desc-version (cdr elt)))
1468 (or (eq packages t) (memq name packages)))
1469 (package--push (package--from-builtin elt) "built-in" info-list)))
1470
1471 ;; Available and disabled packages:
1472 (dolist (elt package-archive-contents)
1473 (setq name (car elt))
1474 (when (or (eq packages t) (memq name packages))
1475 (dolist (pkg (cdr elt))
1476 ;; Hide obsolete packages.
1477 (unless (package-installed-p (package-desc-name pkg)
1478 (package-desc-version pkg))
1479 (package--push pkg (package-desc-status pkg) info-list)))))
1480
1481 ;; Print the result.
1482 (setq tabulated-list-entries
1483 (mapcar #'package-menu--print-info info-list))))
1484
1485 (defun package-menu--generate (remember-pos packages)
1486 "Populate the Package Menu.
1487 If REMEMBER-POS is non-nil, keep point on the same entry.
1488 PACKAGES should be t, which means to display all known packages,
1489 or a list of package names (symbols) to display."
1490 (package-menu--refresh packages)
1491 (tabulated-list-print remember-pos))
1492
1493 (defun package-menu--print-info (pkg)
1494 "Return a package entry suitable for `tabulated-list-entries'.
1495 PKG has the form (PKG-DESC . STATUS).
1496 Return (PKG-DESC [NAME VERSION STATUS DOC])."
1497 (let* ((pkg-desc (car pkg))
1498 (status (cdr pkg))
1499 (face (pcase status
1500 (`"built-in" 'font-lock-builtin-face)
1501 (`"available" 'default)
1502 (`"new" 'bold)
1503 (`"held" 'font-lock-constant-face)
1504 (`"disabled" 'font-lock-warning-face)
1505 (`"installed" 'font-lock-comment-face)
1506 (_ 'font-lock-warning-face)))) ; obsolete.
1507 (list pkg-desc
1508 (vector (list (symbol-name (package-desc-name pkg-desc))
1509 'face 'link
1510 'follow-link t
1511 'package-desc pkg-desc
1512 'action 'package-menu-describe-package)
1513 (propertize (package-version-join
1514 (package-desc-version pkg-desc))
1515 'font-lock-face face)
1516 (propertize status 'font-lock-face face)
1517 (propertize (package-desc-summary pkg-desc)
1518 'font-lock-face face)))))
1519
1520 (defun package-menu-refresh ()
1521 "Download the Emacs Lisp package archive.
1522 This fetches the contents of each archive specified in
1523 `package-archives', and then refreshes the package menu."
1524 (interactive)
1525 (unless (derived-mode-p 'package-menu-mode)
1526 (error "The current buffer is not a Package Menu"))
1527 (package-refresh-contents)
1528 (package-menu--generate t t))
1529
1530 (defun package-menu-describe-package (&optional button)
1531 "Describe the current package.
1532 If optional arg BUTTON is non-nil, describe its associated package."
1533 (interactive)
1534 (let ((pkg-desc (if button (button-get button 'package-desc)
1535 (tabulated-list-get-id))))
1536 (if pkg-desc
1537 (describe-package pkg-desc)
1538 (error "No package here"))))
1539
1540 ;; fixme numeric argument
1541 (defun package-menu-mark-delete (&optional _num)
1542 "Mark a package for deletion and move to the next line."
1543 (interactive "p")
1544 (if (member (package-menu-get-status) '("installed" "obsolete"))
1545 (tabulated-list-put-tag "D" t)
1546 (forward-line)))
1547
1548 (defun package-menu-mark-install (&optional _num)
1549 "Mark a package for installation and move to the next line."
1550 (interactive "p")
1551 (if (member (package-menu-get-status) '("available" "new"))
1552 (tabulated-list-put-tag "I" t)
1553 (forward-line)))
1554
1555 (defun package-menu-mark-unmark (&optional _num)
1556 "Clear any marks on a package and move to the next line."
1557 (interactive "p")
1558 (tabulated-list-put-tag " " t))
1559
1560 (defun package-menu-backup-unmark ()
1561 "Back up one line and clear any marks on that package."
1562 (interactive)
1563 (forward-line -1)
1564 (tabulated-list-put-tag " "))
1565
1566 (defun package-menu-mark-obsolete-for-deletion ()
1567 "Mark all obsolete packages for deletion."
1568 (interactive)
1569 (save-excursion
1570 (goto-char (point-min))
1571 (while (not (eobp))
1572 (if (equal (package-menu-get-status) "obsolete")
1573 (tabulated-list-put-tag "D" t)
1574 (forward-line 1)))))
1575
1576 (defun package-menu-quick-help ()
1577 "Show short key binding help for package-menu-mode."
1578 (interactive)
1579 (message "n-ext, i-nstall, d-elete, u-nmark, x-ecute, r-efresh, h-elp"))
1580
1581 (define-obsolete-function-alias
1582 'package-menu-view-commentary 'package-menu-describe-package "24.1")
1583
1584 (defun package-menu-get-status ()
1585 (let* ((id (tabulated-list-get-id))
1586 (entry (and id (assq id tabulated-list-entries))))
1587 (if entry
1588 (aref (cadr entry) 2)
1589 "")))
1590
1591 (defun package-menu--find-upgrades ()
1592 (let (installed available upgrades)
1593 ;; Build list of installed/available packages in this buffer.
1594 (dolist (entry tabulated-list-entries)
1595 ;; ENTRY is (PKG-DESC [NAME VERSION STATUS DOC])
1596 (let ((pkg-desc (car entry))
1597 (status (aref (cadr entry) 2)))
1598 (cond ((equal status "installed")
1599 (push pkg-desc installed))
1600 ((member status '("available" "new"))
1601 (push (cons (package-desc-name pkg-desc) pkg-desc)
1602 available)))))
1603 ;; Loop through list of installed packages, finding upgrades.
1604 (dolist (pkg-desc installed)
1605 (let ((avail-pkg (assq (package-desc-name pkg-desc) available)))
1606 (and avail-pkg
1607 (version-list-< (package-desc-version pkg-desc)
1608 (package-desc-version (cdr avail-pkg)))
1609 (push avail-pkg upgrades))))
1610 upgrades))
1611
1612 (defun package-menu-mark-upgrades ()
1613 "Mark all upgradable packages in the Package Menu.
1614 For each installed package with a newer version available, place
1615 an (I)nstall flag on the available version and a (D)elete flag on
1616 the installed version. A subsequent \\[package-menu-execute]
1617 call will upgrade the package."
1618 (interactive)
1619 (unless (derived-mode-p 'package-menu-mode)
1620 (error "The current buffer is not a Package Menu"))
1621 (let ((upgrades (package-menu--find-upgrades)))
1622 (if (null upgrades)
1623 (message "No packages to upgrade.")
1624 (widen)
1625 (save-excursion
1626 (goto-char (point-min))
1627 (while (not (eobp))
1628 (let* ((pkg-desc (tabulated-list-get-id))
1629 (upgrade (cdr (assq (package-desc-name pkg-desc) upgrades))))
1630 (cond ((null upgrade)
1631 (forward-line 1))
1632 ((equal pkg-desc upgrade)
1633 (package-menu-mark-install))
1634 (t
1635 (package-menu-mark-delete))))))
1636 (message "%d package%s marked for upgrading."
1637 (length upgrades)
1638 (if (= (length upgrades) 1) "" "s")))))
1639
1640 (defun package-menu-execute (&optional noquery)
1641 "Perform marked Package Menu actions.
1642 Packages marked for installation are downloaded and installed;
1643 packages marked for deletion are removed.
1644 Optional argument NOQUERY non-nil means do not ask the user to confirm."
1645 (interactive)
1646 (unless (derived-mode-p 'package-menu-mode)
1647 (error "The current buffer is not in Package Menu mode"))
1648 (let (install-list delete-list cmd pkg-desc)
1649 (save-excursion
1650 (goto-char (point-min))
1651 (while (not (eobp))
1652 (setq cmd (char-after))
1653 (unless (eq cmd ?\s)
1654 ;; This is the key PKG-DESC.
1655 (setq pkg-desc (tabulated-list-get-id))
1656 (cond ((eq cmd ?D)
1657 (push pkg-desc delete-list))
1658 ((eq cmd ?I)
1659 (push pkg-desc install-list))))
1660 (forward-line)))
1661 (when install-list
1662 (if (or
1663 noquery
1664 (yes-or-no-p
1665 (if (= (length install-list) 1)
1666 (format "Install package `%s'? "
1667 (package-desc-full-name (car install-list)))
1668 (format "Install these %d packages (%s)? "
1669 (length install-list)
1670 (mapconcat #'package-desc-full-name
1671 install-list ", ")))))
1672 (mapc 'package-install install-list)))
1673 ;; Delete packages, prompting if necessary.
1674 (when delete-list
1675 (if (or
1676 noquery
1677 (yes-or-no-p
1678 (if (= (length delete-list) 1)
1679 (format "Delete package `%s'? "
1680 (package-desc-full-name (car delete-list)))
1681 (format "Delete these %d packages (%s)? "
1682 (length delete-list)
1683 (mapconcat #'package-desc-full-name
1684 delete-list ", ")))))
1685 (dolist (elt delete-list)
1686 (condition-case-unless-debug err
1687 (package-delete elt)
1688 (error (message (cadr err)))))
1689 (error "Aborted")))
1690 (if (or delete-list install-list)
1691 (package-menu--generate t t)
1692 (message "No operations specified."))))
1693
1694 (defun package-menu--version-predicate (A B)
1695 (let ((vA (or (aref (cadr A) 1) '(0)))
1696 (vB (or (aref (cadr B) 1) '(0))))
1697 (if (version-list-= vA vB)
1698 (package-menu--name-predicate A B)
1699 (version-list-< vA vB))))
1700
1701 (defun package-menu--status-predicate (A B)
1702 (let ((sA (aref (cadr A) 2))
1703 (sB (aref (cadr B) 2)))
1704 (cond ((string= sA sB)
1705 (package-menu--name-predicate A B))
1706 ((string= sA "new") t)
1707 ((string= sB "new") nil)
1708 ((string= sA "available") t)
1709 ((string= sB "available") nil)
1710 ((string= sA "installed") t)
1711 ((string= sB "installed") nil)
1712 ((string= sA "held") t)
1713 ((string= sB "held") nil)
1714 ((string= sA "built-in") t)
1715 ((string= sB "built-in") nil)
1716 ((string= sA "obsolete") t)
1717 ((string= sB "obsolete") nil)
1718 (t (string< sA sB)))))
1719
1720 (defun package-menu--description-predicate (A B)
1721 (let ((dA (aref (cadr A) 3))
1722 (dB (aref (cadr B) 3)))
1723 (if (string= dA dB)
1724 (package-menu--name-predicate A B)
1725 (string< dA dB))))
1726
1727 (defun package-menu--name-predicate (A B)
1728 (string< (symbol-name (package-desc-name (car A)))
1729 (symbol-name (package-desc-name (car B)))))
1730
1731 ;;;###autoload
1732 (defun list-packages (&optional no-fetch)
1733 "Display a list of packages.
1734 This first fetches the updated list of packages before
1735 displaying, unless a prefix argument NO-FETCH is specified.
1736 The list is displayed in a buffer named `*Packages*'."
1737 (interactive "P")
1738 (require 'finder-inf nil t)
1739 ;; Initialize the package system if necessary.
1740 (unless package--initialized
1741 (package-initialize t))
1742 (let (old-archives new-packages)
1743 (unless no-fetch
1744 ;; Read the locally-cached archive-contents.
1745 (package-read-all-archive-contents)
1746 (setq old-archives package-archive-contents)
1747 ;; Fetch the remote list of packages.
1748 (package-refresh-contents)
1749 ;; Find which packages are new.
1750 (dolist (elt package-archive-contents)
1751 (unless (assq (car elt) old-archives)
1752 (push (car elt) new-packages))))
1753
1754 ;; Generate the Package Menu.
1755 (let ((buf (get-buffer-create "*Packages*")))
1756 (with-current-buffer buf
1757 (package-menu-mode)
1758 (set (make-local-variable 'package-menu--new-package-list)
1759 new-packages)
1760 (package-menu--generate nil t))
1761 ;; The package menu buffer has keybindings. If the user types
1762 ;; `M-x list-packages', that suggests it should become current.
1763 (switch-to-buffer buf))
1764
1765 (let ((upgrades (package-menu--find-upgrades)))
1766 (if upgrades
1767 (message "%d package%s can be upgraded; type `%s' to mark %s for upgrading."
1768 (length upgrades)
1769 (if (= (length upgrades) 1) "" "s")
1770 (substitute-command-keys "\\[package-menu-mark-upgrades]")
1771 (if (= (length upgrades) 1) "it" "them"))))))
1772
1773 ;;;###autoload
1774 (defalias 'package-list-packages 'list-packages)
1775
1776 ;; Used in finder.el
1777 (defun package-show-package-list (packages)
1778 "Display PACKAGES in a *Packages* buffer.
1779 This is similar to `list-packages', but it does not fetch the
1780 updated list of packages, and it only displays packages with
1781 names in PACKAGES (which should be a list of symbols)."
1782 (require 'finder-inf nil t)
1783 (let ((buf (get-buffer-create "*Packages*")))
1784 (with-current-buffer buf
1785 (package-menu-mode)
1786 (package-menu--generate nil packages))
1787 (switch-to-buffer buf)))
1788
1789 (defun package-list-packages-no-fetch ()
1790 "Display a list of packages.
1791 Does not fetch the updated list of packages before displaying.
1792 The list is displayed in a buffer named `*Packages*'."
1793 (interactive)
1794 (list-packages t))
1795
1796 (provide 'package)
1797
1798 ;;; package.el ends here