]> code.delx.au - gnu-emacs/blob - lisp/emacs-lisp/package.el
* lisp/emacs-lisp/package.el (package-generate-autoloads): Remove `require'
[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 (let* ((auto-name (format "%s-autoloads.el" name))
601 ;;(ignore-name (concat name "-pkg.el"))
602 (generated-autoload-file (expand-file-name auto-name pkg-dir))
603 (version-control 'never))
604 (package-autoload-ensure-default-file generated-autoload-file)
605 (update-directory-autoloads pkg-dir)
606 (let ((buf (find-buffer-visiting generated-autoload-file)))
607 (when buf (kill-buffer buf)))
608 auto-name))
609
610 (defvar tar-parse-info)
611 (declare-function tar-untar-buffer "tar-mode" ())
612 (declare-function tar-header-name "tar-mode" (tar-header) t)
613 (declare-function tar-header-link-type "tar-mode" (tar-header) t)
614
615 (defun package-untar-buffer (dir)
616 "Untar the current buffer.
617 This uses `tar-untar-buffer' from Tar mode. All files should
618 untar into a directory named DIR; otherwise, signal an error."
619 (require 'tar-mode)
620 (tar-mode)
621 ;; Make sure everything extracts into DIR.
622 (let ((regexp (concat "\\`" (regexp-quote (expand-file-name dir)) "/"))
623 (case-fold-search (memq system-type '(windows-nt ms-dos cygwin))))
624 (dolist (tar-data tar-parse-info)
625 (let ((name (expand-file-name (tar-header-name tar-data))))
626 (or (string-match regexp name)
627 ;; Tarballs created by some utilities don't list
628 ;; directories with a trailing slash (Bug#13136).
629 (and (string-equal dir name)
630 (eq (tar-header-link-type tar-data) 5))
631 (error "Package does not untar cleanly into directory %s/" dir)))))
632 (tar-untar-buffer))
633
634 (defun package-generate-description-file (pkg-desc pkg-dir)
635 "Create the foo-pkg.el file for single-file packages."
636 (let* ((name (package-desc-name pkg-desc))
637 (pkg-file (expand-file-name (package--description-file pkg-dir)
638 pkg-dir)))
639 (let ((print-level nil)
640 (print-quoted t)
641 (print-length nil))
642 (write-region
643 (concat
644 (prin1-to-string
645 (list 'define-package
646 (symbol-name name)
647 (package-version-join (package-desc-version pkg-desc))
648 (package-desc-summary pkg-desc)
649 (let ((requires (package-desc-reqs pkg-desc)))
650 (list 'quote
651 ;; Turn version lists into string form.
652 (mapcar
653 (lambda (elt)
654 (list (car elt)
655 (package-version-join (cadr elt))))
656 requires)))))
657 "\n")
658 nil
659 pkg-file))))
660
661 (defun package-unpack (pkg-desc)
662 "Install the contents of the current buffer as a package."
663 (let* ((name (package-desc-name pkg-desc))
664 (dirname (package-desc-full-name pkg-desc))
665 (pkg-dir (expand-file-name dirname package-user-dir)))
666 (pcase (package-desc-kind pkg-desc)
667 (`tar
668 (make-directory package-user-dir t)
669 ;; FIXME: should we delete PKG-DIR if it exists?
670 (let* ((default-directory (file-name-as-directory package-user-dir)))
671 (package-untar-buffer dirname)))
672 (`single
673 (let ((el-file (expand-file-name (format "%s.el" name) pkg-dir)))
674 (make-directory pkg-dir t)
675 (package--write-file-no-coding el-file)))
676 (kind (error "Unknown package kind: %S" kind)))
677 (package--make-autoloads-and-stuff pkg-desc pkg-dir)
678 ;; Update package-alist.
679 (let ((new-desc (package-load-descriptor pkg-dir)))
680 ;; FIXME: Check that `new-desc' matches `desc'!
681 ;; FIXME: Compilation should be done as a separate, optional, step.
682 ;; E.g. for multi-package installs, we should first install all packages
683 ;; and then compile them.
684 (package--compile new-desc))
685 ;; Try to activate it.
686 (package-activate name 'force)
687 pkg-dir))
688
689 (defun package--make-autoloads-and-stuff (pkg-desc pkg-dir)
690 "Generate autoloads, description file, etc.. for PKG-DESC installed at PKG-DIR."
691 (package-generate-autoloads (package-desc-name pkg-desc) pkg-dir)
692 (let ((desc-file (package--description-file pkg-dir)))
693 (unless (file-exists-p desc-file)
694 (package-generate-description-file pkg-desc pkg-dir)))
695 ;; FIXME: Create foo.info and dir file from foo.texi?
696 )
697
698 (defun package--compile (pkg-desc)
699 "Byte-compile installed package PKG-DESC."
700 (package-activate-1 pkg-desc)
701 (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))
702
703 (defun package--write-file-no-coding (file-name)
704 (let ((buffer-file-coding-system 'no-conversion))
705 (write-region (point-min) (point-max) file-name)))
706
707 (defmacro package--with-work-buffer (location file &rest body)
708 "Run BODY in a buffer containing the contents of FILE at LOCATION.
709 LOCATION is the base location of a package archive, and should be
710 one of the URLs (or file names) specified in `package-archives'.
711 FILE is the name of a file relative to that base location.
712
713 This macro retrieves FILE from LOCATION into a temporary buffer,
714 and evaluates BODY while that buffer is current. This work
715 buffer is killed afterwards. Return the last value in BODY."
716 (declare (indent 2) (debug t))
717 `(let* ((http (string-match "\\`https?:" ,location))
718 (buffer
719 (if http
720 (url-retrieve-synchronously (concat ,location ,file))
721 (generate-new-buffer "*package work buffer*"))))
722 (prog1
723 (with-current-buffer buffer
724 (if http
725 (progn (package-handle-response)
726 (re-search-forward "^$" nil 'move)
727 (forward-char)
728 (delete-region (point-min) (point)))
729 (unless (file-name-absolute-p ,location)
730 (error "Archive location %s is not an absolute file name"
731 ,location))
732 (insert-file-contents (expand-file-name ,file ,location)))
733 ,@body)
734 (kill-buffer buffer))))
735
736 (defun package-handle-response ()
737 "Handle the response from a `url-retrieve-synchronously' call.
738 Parse the HTTP response and throw if an error occurred.
739 The url package seems to require extra processing for this.
740 This should be called in a `save-excursion', in the download buffer.
741 It will move point to somewhere in the headers."
742 ;; We assume HTTP here.
743 (require 'url-http)
744 (let ((response (url-http-parse-response)))
745 (when (or (< response 200) (>= response 300))
746 (error "Error during download request:%s"
747 (buffer-substring-no-properties (point) (line-end-position))))))
748
749 (defun package-install-from-archive (pkg-desc)
750 "Download and install a tar package."
751 (let ((location (package-archive-base pkg-desc))
752 (file (concat (package-desc-full-name pkg-desc)
753 (package-desc-suffix pkg-desc))))
754 (package--with-work-buffer location file
755 (package-unpack pkg-desc))))
756
757 (defvar package--initialized nil)
758
759 (defun package-installed-p (package &optional min-version)
760 "Return true if PACKAGE, of MIN-VERSION or newer, is installed.
761 MIN-VERSION should be a version list."
762 (unless package--initialized (error "package.el is not yet initialized!"))
763 (or
764 (let ((pkg-descs (cdr (assq package package-alist))))
765 (and pkg-descs
766 (version-list-<= min-version
767 (package-desc-version (car pkg-descs)))))
768 ;; Also check built-in packages.
769 (package-built-in-p package min-version)))
770
771 (defun package-compute-transaction (packages requirements)
772 "Return a list of packages to be installed, including PACKAGES.
773 PACKAGES should be a list of `package-desc'.
774
775 REQUIREMENTS should be a list of additional requirements; each
776 element in this list should have the form (PACKAGE VERSION-LIST),
777 where PACKAGE is a package name and VERSION-LIST is the required
778 version of that package.
779
780 This function recursively computes the requirements of the
781 packages in REQUIREMENTS, and returns a list of all the packages
782 that must be installed. Packages that are already installed are
783 not included in this list."
784 ;; FIXME: We really should use backtracking to explore the whole
785 ;; search space (e.g. if foo require bar-1.3, and bar-1.4 requires toto-1.1
786 ;; whereas bar-1.3 requires toto-1.0 and the user has put a hold on toto-1.0:
787 ;; the current code might fail to see that it could install foo by using the
788 ;; older bar-1.3).
789 (dolist (elt requirements)
790 (let* ((next-pkg (car elt))
791 (next-version (cadr elt))
792 (already ()))
793 (dolist (pkg packages)
794 (if (eq next-pkg (package-desc-name pkg))
795 (setq already pkg)))
796 (cond
797 (already
798 (if (version-list-< next-version (package-desc-version already))
799 ;; Move to front, so it gets installed early enough (bug#14082).
800 (setq packages (cons already (delq already packages)))
801 (error "Need package `%s-%s', but only %s is available"
802 next-pkg (package-version-join next-version)
803 (package-version-join (package-desc-version already)))))
804
805 ((package-installed-p next-pkg next-version) nil)
806
807 (t
808 ;; A package is required, but not installed. It might also be
809 ;; blocked via `package-load-list'.
810 (let ((pkg-descs (cdr (assq next-pkg package-archive-contents)))
811 (found nil)
812 (problem nil))
813 (while (and pkg-descs (not found))
814 (let* ((pkg-desc (pop pkg-descs))
815 (version (package-desc-version pkg-desc))
816 (disabled (package-disabled-p next-pkg version)))
817 (cond
818 ((version-list-< version next-version)
819 (error
820 "Need package `%s-%s', but only %s is available"
821 next-pkg (package-version-join next-version)
822 (package-version-join version)))
823 (disabled
824 (unless problem
825 (setq problem
826 (if (stringp disabled)
827 (format "Package `%s' held at version %s, \
828 but version %s required"
829 next-pkg disabled
830 (package-version-join next-version))
831 (format "Required package '%s' is disabled"
832 next-pkg)))))
833 (t (setq found pkg-desc)))))
834 (unless found
835 (if problem
836 (error problem)
837 (error "Package `%s-%s' is unavailable"
838 next-pkg (package-version-join next-version))))
839 (setq packages
840 (package-compute-transaction (cons found packages)
841 (package-desc-reqs found))))))))
842 packages)
843
844 (defun package-read-from-string (str)
845 "Read a Lisp expression from STR.
846 Signal an error if the entire string was not used."
847 (let* ((read-data (read-from-string str))
848 (more-left
849 (condition-case nil
850 ;; The call to `ignore' suppresses a compiler warning.
851 (progn (ignore (read-from-string
852 (substring str (cdr read-data))))
853 t)
854 (end-of-file nil))))
855 (if more-left
856 (error "Can't read whole string")
857 (car read-data))))
858
859 (defun package--read-archive-file (file)
860 "Re-read archive file FILE, if it exists.
861 Will return the data from the file, or nil if the file does not exist.
862 Will throw an error if the archive version is too new."
863 (let ((filename (expand-file-name file package-user-dir)))
864 (when (file-exists-p filename)
865 (with-temp-buffer
866 (insert-file-contents-literally filename)
867 (let ((contents (read (current-buffer))))
868 (if (> (car contents) package-archive-version)
869 (error "Package archive version %d is higher than %d"
870 (car contents) package-archive-version))
871 (cdr contents))))))
872
873 (defun package-read-all-archive-contents ()
874 "Re-read `archive-contents', if it exists.
875 If successful, set `package-archive-contents'."
876 (setq package-archive-contents nil)
877 (dolist (archive package-archives)
878 (package-read-archive-contents (car archive))))
879
880 (defun package-read-archive-contents (archive)
881 "Re-read archive contents for ARCHIVE.
882 If successful, set the variable `package-archive-contents'.
883 If the archive version is too new, signal an error."
884 ;; Version 1 of 'archive-contents' is identical to our internal
885 ;; representation.
886 (let* ((contents-file (format "archives/%s/archive-contents" archive))
887 (contents (package--read-archive-file contents-file)))
888 (when contents
889 (dolist (package contents)
890 (package--add-to-archive-contents package archive)))))
891
892 ;; Package descriptor objects used inside the "archive-contents" file.
893 ;; Changing this defstruct implies changing the format of the
894 ;; "archive-contents" files.
895 (cl-defstruct (package--ac-desc
896 (:constructor package-make-ac-desc (version reqs summary kind))
897 (:copier nil)
898 (:type vector))
899 version reqs summary kind)
900
901 (defun package--add-to-archive-contents (package archive)
902 "Add the PACKAGE from the given ARCHIVE if necessary.
903 PACKAGE should have the form (NAME . PACKAGE--AC-DESC).
904 Also, add the originating archive to the `package-desc' structure."
905 (let* ((name (car package))
906 (version (package--ac-desc-version (cdr package)))
907 (pkg-desc
908 (package-desc-create
909 :name name
910 :version version
911 :reqs (package--ac-desc-reqs (cdr package))
912 :summary (package--ac-desc-summary (cdr package))
913 :kind (package--ac-desc-kind (cdr package))
914 :archive archive))
915 (existing-packages (assq name package-archive-contents))
916 (pinned-to-archive (assoc name package-pinned-packages)))
917 (cond
918 ;; Skip entirely if pinned to another archive or already installed.
919 ((or (and pinned-to-archive
920 (not (equal (cdr pinned-to-archive) archive)))
921 (let ((bi (assq name package--builtin-versions)))
922 (and bi (version-list-= version (cdr bi))))
923 (let ((ins (cdr (assq name package-alist))))
924 (and ins (version-list-= version
925 (package-desc-version (car ins))))))
926 nil)
927 ((not existing-packages)
928 (push (list name pkg-desc) package-archive-contents))
929 (t
930 (while
931 (if (and (cdr existing-packages)
932 (version-list-<
933 version (package-desc-version (cadr existing-packages))))
934 (setq existing-packages (cdr existing-packages))
935 (push pkg-desc (cdr existing-packages))
936 nil))))))
937
938 (defun package-download-transaction (packages)
939 "Download and install all the packages in PACKAGES.
940 PACKAGES should be a list of package-desc.
941 This function assumes that all package requirements in
942 PACKAGES are satisfied, i.e. that PACKAGES is computed
943 using `package-compute-transaction'."
944 (mapc #'package-install-from-archive packages))
945
946 ;;;###autoload
947 (defun package-install (pkg)
948 "Install the package PKG.
949 PKG can be a package-desc or the package name of one the available packages
950 in an archive in `package-archives'. Interactively, prompt for its name."
951 (interactive
952 (progn
953 ;; Initialize the package system to get the list of package
954 ;; symbols for completion.
955 (unless package--initialized
956 (package-initialize t))
957 (unless package-archive-contents
958 (package-refresh-contents))
959 (list (intern (completing-read
960 "Install package: "
961 (mapcar (lambda (elt) (symbol-name (car elt)))
962 package-archive-contents)
963 nil t)))))
964 (package-download-transaction
965 (if (package-desc-p pkg)
966 (package-compute-transaction (list pkg)
967 (package-desc-reqs pkg))
968 (package-compute-transaction ()
969 (list (list pkg))))))
970
971 (defun package-strip-rcs-id (str)
972 "Strip RCS version ID from the version string STR.
973 If the result looks like a dotted numeric version, return it.
974 Otherwise return nil."
975 (when str
976 (when (string-match "\\`[ \t]*[$]Revision:[ \t]+" str)
977 (setq str (substring str (match-end 0))))
978 (condition-case nil
979 (if (version-to-list str)
980 str)
981 (error nil))))
982
983 (defun package-buffer-info ()
984 "Return a `package-desc' describing the package in the current buffer.
985
986 If the buffer does not contain a conforming package, signal an
987 error. If there is a package, narrow the buffer to the file's
988 boundaries."
989 (goto-char (point-min))
990 (unless (re-search-forward "^;;; \\([^ ]*\\)\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" nil t)
991 (error "Package lacks a file header"))
992 (let ((file-name (match-string-no-properties 1))
993 (desc (match-string-no-properties 2))
994 (start (line-beginning-position)))
995 (unless (search-forward (concat ";;; " file-name ".el ends here"))
996 (error "Package lacks a terminating comment"))
997 ;; Try to include a trailing newline.
998 (forward-line)
999 (narrow-to-region start (point))
1000 (require 'lisp-mnt)
1001 ;; Use some headers we've invented to drive the process.
1002 (let* ((requires-str (lm-header "package-requires"))
1003 ;; Prefer Package-Version; if defined, the package author
1004 ;; probably wants us to use it. Otherwise try Version.
1005 (pkg-version
1006 (or (package-strip-rcs-id (lm-header "package-version"))
1007 (package-strip-rcs-id (lm-header "version")))))
1008 (unless pkg-version
1009 (error
1010 "Package lacks a \"Version\" or \"Package-Version\" header"))
1011 (package-desc-from-define
1012 file-name pkg-version desc
1013 (if requires-str (package-read-from-string requires-str))
1014 :kind 'single))))
1015
1016 (declare-function tar-get-file-descriptor "tar-mode" (file))
1017 (declare-function tar--extract "tar-mode" (descriptor))
1018
1019 (defun package-tar-file-info ()
1020 "Find package information for a tar file.
1021 The return result is a `package-desc'."
1022 (cl-assert (derived-mode-p 'tar-mode))
1023 (let* ((dir-name (file-name-directory
1024 (tar-header-name (car tar-parse-info))))
1025 (desc-file (package--description-file dir-name))
1026 (tar-desc (tar-get-file-descriptor (concat dir-name desc-file))))
1027 (unless tar-desc
1028 (error "No package descriptor file found"))
1029 (with-current-buffer (tar--extract tar-desc)
1030 (goto-char (point-min))
1031 (unwind-protect
1032 (let* ((pkg-def-parsed (read (current-buffer)))
1033 (pkg-desc
1034 (if (not (eq (car pkg-def-parsed) 'define-package))
1035 (error "Can't find define-package in %s"
1036 (tar-header-name tar-desc))
1037 (apply #'package-desc-from-define
1038 (append (cdr pkg-def-parsed))))))
1039 (setf (package-desc-kind pkg-desc) 'tar)
1040 pkg-desc)
1041 (kill-buffer (current-buffer))))))
1042
1043
1044 ;;;###autoload
1045 (defun package-install-from-buffer ()
1046 "Install a package from the current buffer.
1047 The current buffer is assumed to be a single .el or .tar file that follows the
1048 packaging guidelines; see info node `(elisp)Packaging'.
1049 Downloads and installs required packages as needed."
1050 (interactive)
1051 (let ((pkg-desc (if (derived-mode-p 'tar-mode)
1052 (package-tar-file-info)
1053 (package-buffer-info))))
1054 ;; Download and install the dependencies.
1055 (let* ((requires (package-desc-reqs pkg-desc))
1056 (transaction (package-compute-transaction nil requires)))
1057 (package-download-transaction transaction))
1058 ;; Install the package itself.
1059 (package-unpack pkg-desc)
1060 pkg-desc))
1061
1062 ;;;###autoload
1063 (defun package-install-file (file)
1064 "Install a package from a file.
1065 The file can either be a tar file or an Emacs Lisp file."
1066 (interactive "fPackage file name: ")
1067 (with-temp-buffer
1068 (insert-file-contents-literally file)
1069 (when (string-match "\\.tar\\'" file) (tar-mode))
1070 (package-install-from-buffer)))
1071
1072 (defun package-delete (pkg-desc)
1073 (let ((dir (package-desc-dir pkg-desc)))
1074 (if (not (string-prefix-p (file-name-as-directory
1075 (expand-file-name package-user-dir))
1076 (expand-file-name dir)))
1077 ;; Don't delete "system" packages.
1078 (error "Package `%s' is a system package, not deleting"
1079 (package-desc-full-name pkg-desc))
1080 (delete-directory dir t t)
1081 ;; Update package-alist.
1082 (let* ((name (package-desc-name pkg-desc)))
1083 (delete pkg-desc (assq name package-alist)))
1084 (message "Package `%s' deleted." (package-desc-full-name pkg-desc)))))
1085
1086 (defun package-archive-base (desc)
1087 "Return the archive containing the package NAME."
1088 (cdr (assoc (package-desc-archive desc) package-archives)))
1089
1090 (defun package--download-one-archive (archive file)
1091 "Retrieve an archive file FILE from ARCHIVE, and cache it.
1092 ARCHIVE should be a cons cell of the form (NAME . LOCATION),
1093 similar to an entry in `package-alist'. Save the cached copy to
1094 \"archives/NAME/archive-contents\" in `package-user-dir'."
1095 (let* ((dir (expand-file-name (format "archives/%s" (car archive))
1096 package-user-dir)))
1097 (package--with-work-buffer (cdr archive) file
1098 ;; Read the retrieved buffer to make sure it is valid (e.g. it
1099 ;; may fetch a URL redirect page).
1100 (when (listp (read buffer))
1101 (make-directory dir t)
1102 (setq buffer-file-name (expand-file-name file dir))
1103 (let ((version-control 'never))
1104 (save-buffer))))))
1105
1106 ;;;###autoload
1107 (defun package-refresh-contents ()
1108 "Download the ELPA archive description if needed.
1109 This informs Emacs about the latest versions of all packages, and
1110 makes them available for download."
1111 (interactive)
1112 ;; FIXME: Do it asynchronously.
1113 (unless (file-exists-p package-user-dir)
1114 (make-directory package-user-dir t))
1115 (dolist (archive package-archives)
1116 (condition-case-unless-debug nil
1117 (package--download-one-archive archive "archive-contents")
1118 (error (message "Failed to download `%s' archive."
1119 (car archive)))))
1120 (package-read-all-archive-contents))
1121
1122 ;;;###autoload
1123 (defun package-initialize (&optional no-activate)
1124 "Load Emacs Lisp packages, and activate them.
1125 The variable `package-load-list' controls which packages to load.
1126 If optional arg NO-ACTIVATE is non-nil, don't activate packages."
1127 (interactive)
1128 (setq package-alist nil)
1129 (package-load-all-descriptors)
1130 (package-read-all-archive-contents)
1131 (unless no-activate
1132 (dolist (elt package-alist)
1133 (package-activate (car elt))))
1134 (setq package--initialized t))
1135
1136 \f
1137 ;;;; Package description buffer.
1138
1139 ;;;###autoload
1140 (defun describe-package (package)
1141 "Display the full documentation of PACKAGE (a symbol)."
1142 (interactive
1143 (let* ((guess (function-called-at-point)))
1144 (require 'finder-inf nil t)
1145 ;; Load the package list if necessary (but don't activate them).
1146 (unless package--initialized
1147 (package-initialize t))
1148 (let ((packages (append (mapcar 'car package-alist)
1149 (mapcar 'car package-archive-contents)
1150 (mapcar 'car package--builtins))))
1151 (unless (memq guess packages)
1152 (setq guess nil))
1153 (setq packages (mapcar 'symbol-name packages))
1154 (let ((val
1155 (completing-read (if guess
1156 (format "Describe package (default %s): "
1157 guess)
1158 "Describe package: ")
1159 packages nil t nil nil guess)))
1160 (list (intern val))))))
1161 (if (not (or (package-desc-p package) (and package (symbolp package))))
1162 (message "No package specified")
1163 (help-setup-xref (list #'describe-package package)
1164 (called-interactively-p 'interactive))
1165 (with-help-window (help-buffer)
1166 (with-current-buffer standard-output
1167 (describe-package-1 package)))))
1168
1169 (defun describe-package-1 (pkg)
1170 (require 'lisp-mnt)
1171 (let* ((desc (or
1172 (if (package-desc-p pkg) pkg)
1173 (cadr (assq pkg package-alist))
1174 (let ((built-in (assq pkg package--builtins)))
1175 (if built-in
1176 (package--from-builtin built-in)
1177 (cadr (assq pkg package-archive-contents))))))
1178 (name (if desc (package-desc-name desc) pkg))
1179 (pkg-dir (if desc (package-desc-dir desc)))
1180 (reqs (if desc (package-desc-reqs desc)))
1181 (version (if desc (package-desc-version desc)))
1182 (archive (if desc (package-desc-archive desc)))
1183 (built-in (eq pkg-dir 'builtin))
1184 (installable (and archive (not built-in)))
1185 (status (if desc (package-desc-status desc) "orphan")))
1186 (prin1 name)
1187 (princ " is ")
1188 (princ (if (memq (aref status 0) '(?a ?e ?i ?o ?u)) "an " "a "))
1189 (princ status)
1190 (princ " package.\n\n")
1191
1192 (insert " " (propertize "Status" 'font-lock-face 'bold) ": ")
1193 (cond (built-in
1194 (insert (propertize (capitalize status)
1195 'font-lock-face 'font-lock-builtin-face)
1196 "."))
1197 (pkg-dir
1198 (insert (propertize (capitalize status) ;FIXME: Why comment-face?
1199 'font-lock-face 'font-lock-comment-face))
1200 (insert " in `")
1201 ;; Todo: Add button for uninstalling.
1202 (help-insert-xref-button (abbreviate-file-name
1203 (file-name-as-directory pkg-dir))
1204 'help-package-def pkg-dir)
1205 (if (and (package-built-in-p name)
1206 (not (package-built-in-p name version)))
1207 (insert "',\n shadowing a "
1208 (propertize "built-in package"
1209 'font-lock-face 'font-lock-builtin-face)
1210 ".")
1211 (insert "'.")))
1212 (installable
1213 (insert (capitalize status))
1214 (insert " from " (format "%s" archive))
1215 (insert " -- ")
1216 (let ((button-text (if (display-graphic-p) "Install" "[Install]"))
1217 (button-face (if (display-graphic-p)
1218 '(:box (:line-width 2 :color "dark grey")
1219 :background "light grey"
1220 :foreground "black")
1221 'link)))
1222 (insert-text-button button-text 'face button-face 'follow-link t
1223 'package-desc desc
1224 'action 'package-install-button-action)))
1225 (t (insert (capitalize status) ".")))
1226 (insert "\n")
1227 (and version
1228 (insert " "
1229 (propertize "Version" 'font-lock-face 'bold) ": "
1230 (package-version-join version) "\n"))
1231
1232 (setq reqs (if desc (package-desc-reqs desc)))
1233 (when reqs
1234 (insert " " (propertize "Requires" 'font-lock-face 'bold) ": ")
1235 (let ((first t)
1236 name vers text)
1237 (dolist (req reqs)
1238 (setq name (car req)
1239 vers (cadr req)
1240 text (format "%s-%s" (symbol-name name)
1241 (package-version-join vers)))
1242 (cond (first (setq first nil))
1243 ((>= (+ 2 (current-column) (length text))
1244 (window-width))
1245 (insert ",\n "))
1246 (t (insert ", ")))
1247 (help-insert-xref-button text 'help-package name))
1248 (insert "\n")))
1249 (insert " " (propertize "Summary" 'font-lock-face 'bold)
1250 ": " (if desc (package-desc-summary desc)) "\n")
1251
1252 (let* ((all-pkgs (append (cdr (assq name package-alist))
1253 (cdr (assq name package-archive-contents))
1254 (let ((bi (assq name package--builtins)))
1255 (if bi (list (package--from-builtin bi))))))
1256 (other-pkgs (delete desc all-pkgs)))
1257 (when other-pkgs
1258 (insert " " (propertize "Other versions" 'font-lock-face 'bold) ": "
1259 (mapconcat
1260 (lambda (opkg)
1261 (let* ((ov (package-desc-version opkg))
1262 (dir (package-desc-dir opkg))
1263 (from (or (package-desc-archive opkg)
1264 (if (stringp dir) "installed" dir))))
1265 (if (not ov) (format "%s" from)
1266 (format "%s (%s)"
1267 (make-text-button (package-version-join ov) nil
1268 'face 'link
1269 'follow-link t
1270 'action
1271 (lambda (_button)
1272 (describe-package opkg)))
1273 from))))
1274 other-pkgs ", ")
1275 ".\n")))
1276
1277 (insert "\n")
1278
1279 (if built-in
1280 ;; For built-in packages, insert the commentary.
1281 (let ((fn (locate-file (format "%s.el" name) load-path
1282 load-file-rep-suffixes))
1283 (opoint (point)))
1284 (insert (or (lm-commentary fn) ""))
1285 (save-excursion
1286 (goto-char opoint)
1287 (when (re-search-forward "^;;; Commentary:\n" nil t)
1288 (replace-match ""))
1289 (while (re-search-forward "^\\(;+ ?\\)" nil t)
1290 (replace-match ""))))
1291 (let ((readme (expand-file-name (format "%s-readme.txt" name)
1292 package-user-dir))
1293 readme-string)
1294 ;; For elpa packages, try downloading the commentary. If that
1295 ;; fails, try an existing readme file in `package-user-dir'.
1296 (cond ((condition-case nil
1297 (package--with-work-buffer
1298 (package-archive-base desc)
1299 (format "%s-readme.txt" name)
1300 (setq buffer-file-name
1301 (expand-file-name readme package-user-dir))
1302 (let ((version-control 'never))
1303 (save-buffer))
1304 (setq readme-string (buffer-string))
1305 t)
1306 (error nil))
1307 (insert readme-string))
1308 ((file-readable-p readme)
1309 (insert-file-contents readme)
1310 (goto-char (point-max))))))))
1311
1312 (defun package-install-button-action (button)
1313 (let ((pkg-desc (button-get button 'package-desc)))
1314 (when (y-or-n-p (format "Install package `%s'? "
1315 (package-desc-full-name pkg-desc)))
1316 (package-install pkg-desc)
1317 (revert-buffer nil t)
1318 (goto-char (point-min)))))
1319
1320 \f
1321 ;;;; Package menu mode.
1322
1323 (defvar package-menu-mode-map
1324 (let ((map (make-sparse-keymap))
1325 (menu-map (make-sparse-keymap "Package")))
1326 (set-keymap-parent map tabulated-list-mode-map)
1327 (define-key map "\C-m" 'package-menu-describe-package)
1328 (define-key map "u" 'package-menu-mark-unmark)
1329 (define-key map "\177" 'package-menu-backup-unmark)
1330 (define-key map "d" 'package-menu-mark-delete)
1331 (define-key map "i" 'package-menu-mark-install)
1332 (define-key map "U" 'package-menu-mark-upgrades)
1333 (define-key map "r" 'package-menu-refresh)
1334 (define-key map "~" 'package-menu-mark-obsolete-for-deletion)
1335 (define-key map "x" 'package-menu-execute)
1336 (define-key map "h" 'package-menu-quick-help)
1337 (define-key map "?" 'package-menu-describe-package)
1338 (define-key map [menu-bar package-menu] (cons "Package" menu-map))
1339 (define-key menu-map [mq]
1340 '(menu-item "Quit" quit-window
1341 :help "Quit package selection"))
1342 (define-key menu-map [s1] '("--"))
1343 (define-key menu-map [mn]
1344 '(menu-item "Next" next-line
1345 :help "Next Line"))
1346 (define-key menu-map [mp]
1347 '(menu-item "Previous" previous-line
1348 :help "Previous Line"))
1349 (define-key menu-map [s2] '("--"))
1350 (define-key menu-map [mu]
1351 '(menu-item "Unmark" package-menu-mark-unmark
1352 :help "Clear any marks on a package and move to the next line"))
1353 (define-key menu-map [munm]
1354 '(menu-item "Unmark Backwards" package-menu-backup-unmark
1355 :help "Back up one line and clear any marks on that package"))
1356 (define-key menu-map [md]
1357 '(menu-item "Mark for Deletion" package-menu-mark-delete
1358 :help "Mark a package for deletion and move to the next line"))
1359 (define-key menu-map [mi]
1360 '(menu-item "Mark for Install" package-menu-mark-install
1361 :help "Mark a package for installation and move to the next line"))
1362 (define-key menu-map [mupgrades]
1363 '(menu-item "Mark Upgradable Packages" package-menu-mark-upgrades
1364 :help "Mark packages that have a newer version for upgrading"))
1365 (define-key menu-map [s3] '("--"))
1366 (define-key menu-map [mg]
1367 '(menu-item "Update Package List" revert-buffer
1368 :help "Update the list of packages"))
1369 (define-key menu-map [mr]
1370 '(menu-item "Refresh Package List" package-menu-refresh
1371 :help "Download the ELPA archive"))
1372 (define-key menu-map [s4] '("--"))
1373 (define-key menu-map [mt]
1374 '(menu-item "Mark Obsolete Packages" package-menu-mark-obsolete-for-deletion
1375 :help "Mark all obsolete packages for deletion"))
1376 (define-key menu-map [mx]
1377 '(menu-item "Execute Actions" package-menu-execute
1378 :help "Perform all the marked actions"))
1379 (define-key menu-map [s5] '("--"))
1380 (define-key menu-map [mh]
1381 '(menu-item "Help" package-menu-quick-help
1382 :help "Show short key binding help for package-menu-mode"))
1383 (define-key menu-map [mc]
1384 '(menu-item "View Commentary" package-menu-view-commentary
1385 :help "Display information about this package"))
1386 map)
1387 "Local keymap for `package-menu-mode' buffers.")
1388
1389 (defvar package-menu--new-package-list nil
1390 "List of newly-available packages since `list-packages' was last called.")
1391
1392 (define-derived-mode package-menu-mode tabulated-list-mode "Package Menu"
1393 "Major mode for browsing a list of packages.
1394 Letters do not insert themselves; instead, they are commands.
1395 \\<package-menu-mode-map>
1396 \\{package-menu-mode-map}"
1397 (setq tabulated-list-format [("Package" 18 package-menu--name-predicate)
1398 ("Version" 12 nil)
1399 ("Status" 10 package-menu--status-predicate)
1400 ("Description" 0 nil)])
1401 (setq tabulated-list-padding 2)
1402 (setq tabulated-list-sort-key (cons "Status" nil))
1403 (add-hook 'tabulated-list-revert-hook 'package-menu--refresh nil t)
1404 (tabulated-list-init-header))
1405
1406 (defmacro package--push (pkg-desc status listname)
1407 "Convenience macro for `package-menu--generate'.
1408 If the alist stored in the symbol LISTNAME lacks an entry for a
1409 package PKG-DESC, add one. The alist is keyed with PKG-DESC."
1410 `(unless (assoc ,pkg-desc ,listname)
1411 ;; FIXME: Should we move status into pkg-desc?
1412 (push (cons ,pkg-desc ,status) ,listname)))
1413
1414 (defvar package-list-unversioned nil
1415 "If non-nil include packages that don't have a version in `list-package'.")
1416
1417 (defun package-desc-status (pkg-desc)
1418 (let* ((name (package-desc-name pkg-desc))
1419 (dir (package-desc-dir pkg-desc))
1420 (lle (assq name package-load-list))
1421 (held (cadr lle))
1422 (version (package-desc-version pkg-desc)))
1423 (cond
1424 ((eq dir 'builtin) "built-in")
1425 ((and lle (null held)) "disabled")
1426 ((stringp held)
1427 (let ((hv (if (stringp held) (version-to-list held))))
1428 (cond
1429 ((version-list-= version hv) "held")
1430 ((version-list-< version hv) "obsolete")
1431 (t "disabled"))))
1432 ((package-built-in-p name version) "obsolete")
1433 (dir ;One of the installed packages.
1434 (cond
1435 ((not (file-exists-p (package-desc-dir pkg-desc))) "deleted")
1436 ((eq pkg-desc (cadr (assq name package-alist))) "installed")
1437 (t "obsolete")))
1438 (t
1439 (let* ((ins (cadr (assq name package-alist)))
1440 (ins-v (if ins (package-desc-version ins))))
1441 (cond
1442 ((or (null ins) (version-list-< ins-v version))
1443 (if (memq name package-menu--new-package-list)
1444 "new" "available"))
1445 ((version-list-< version ins-v) "obsolete")
1446 ((version-list-= version ins-v) "installed")))))))
1447
1448 (defun package-menu--refresh (&optional packages)
1449 "Re-populate the `tabulated-list-entries'.
1450 PACKAGES should be nil or t, which means to display all known packages."
1451 ;; Construct list of (PKG-DESC . STATUS).
1452 (unless packages (setq packages t))
1453 (let (info-list name)
1454 ;; Installed packages:
1455 (dolist (elt package-alist)
1456 (setq name (car elt))
1457 (when (or (eq packages t) (memq name packages))
1458 (dolist (pkg (cdr elt))
1459 (package--push pkg (package-desc-status pkg) info-list))))
1460
1461 ;; Built-in packages:
1462 (dolist (elt package--builtins)
1463 (setq name (car elt))
1464 (when (and (not (eq name 'emacs)) ; Hide the `emacs' package.
1465 (or package-list-unversioned
1466 (package--bi-desc-version (cdr elt)))
1467 (or (eq packages t) (memq name packages)))
1468 (package--push (package--from-builtin elt) "built-in" info-list)))
1469
1470 ;; Available and disabled packages:
1471 (dolist (elt package-archive-contents)
1472 (setq name (car elt))
1473 (when (or (eq packages t) (memq name packages))
1474 (dolist (pkg (cdr elt))
1475 ;; Hide obsolete packages.
1476 (unless (package-installed-p (package-desc-name pkg)
1477 (package-desc-version pkg))
1478 (package--push pkg (package-desc-status pkg) info-list)))))
1479
1480 ;; Print the result.
1481 (setq tabulated-list-entries
1482 (mapcar #'package-menu--print-info info-list))))
1483
1484 (defun package-menu--generate (remember-pos packages)
1485 "Populate the Package Menu.
1486 If REMEMBER-POS is non-nil, keep point on the same entry.
1487 PACKAGES should be t, which means to display all known packages,
1488 or a list of package names (symbols) to display."
1489 (package-menu--refresh packages)
1490 (tabulated-list-print remember-pos))
1491
1492 (defun package-menu--print-info (pkg)
1493 "Return a package entry suitable for `tabulated-list-entries'.
1494 PKG has the form (PKG-DESC . STATUS).
1495 Return (PKG-DESC [NAME VERSION STATUS DOC])."
1496 (let* ((pkg-desc (car pkg))
1497 (status (cdr pkg))
1498 (face (pcase status
1499 (`"built-in" 'font-lock-builtin-face)
1500 (`"available" 'default)
1501 (`"new" 'bold)
1502 (`"held" 'font-lock-constant-face)
1503 (`"disabled" 'font-lock-warning-face)
1504 (`"installed" 'font-lock-comment-face)
1505 (_ 'font-lock-warning-face)))) ; obsolete.
1506 (list pkg-desc
1507 (vector (list (symbol-name (package-desc-name pkg-desc))
1508 'face 'link
1509 'follow-link t
1510 'package-desc pkg-desc
1511 'action 'package-menu-describe-package)
1512 (propertize (package-version-join
1513 (package-desc-version pkg-desc))
1514 'font-lock-face face)
1515 (propertize status 'font-lock-face face)
1516 (propertize (package-desc-summary pkg-desc)
1517 'font-lock-face face)))))
1518
1519 (defun package-menu-refresh ()
1520 "Download the Emacs Lisp package archive.
1521 This fetches the contents of each archive specified in
1522 `package-archives', and then refreshes the package menu."
1523 (interactive)
1524 (unless (derived-mode-p 'package-menu-mode)
1525 (user-error "The current buffer is not a Package Menu"))
1526 (package-refresh-contents)
1527 (package-menu--generate t t))
1528
1529 (defun package-menu-describe-package (&optional button)
1530 "Describe the current package.
1531 If optional arg BUTTON is non-nil, describe its associated package."
1532 (interactive)
1533 (let ((pkg-desc (if button (button-get button 'package-desc)
1534 (tabulated-list-get-id))))
1535 (if pkg-desc
1536 (describe-package pkg-desc)
1537 (user-error "No package here"))))
1538
1539 ;; fixme numeric argument
1540 (defun package-menu-mark-delete (&optional _num)
1541 "Mark a package for deletion and move to the next line."
1542 (interactive "p")
1543 (if (member (package-menu-get-status) '("installed" "obsolete"))
1544 (tabulated-list-put-tag "D" t)
1545 (forward-line)))
1546
1547 (defun package-menu-mark-install (&optional _num)
1548 "Mark a package for installation and move to the next line."
1549 (interactive "p")
1550 (if (member (package-menu-get-status) '("available" "new"))
1551 (tabulated-list-put-tag "I" t)
1552 (forward-line)))
1553
1554 (defun package-menu-mark-unmark (&optional _num)
1555 "Clear any marks on a package and move to the next line."
1556 (interactive "p")
1557 (tabulated-list-put-tag " " t))
1558
1559 (defun package-menu-backup-unmark ()
1560 "Back up one line and clear any marks on that package."
1561 (interactive)
1562 (forward-line -1)
1563 (tabulated-list-put-tag " "))
1564
1565 (defun package-menu-mark-obsolete-for-deletion ()
1566 "Mark all obsolete packages for deletion."
1567 (interactive)
1568 (save-excursion
1569 (goto-char (point-min))
1570 (while (not (eobp))
1571 (if (equal (package-menu-get-status) "obsolete")
1572 (tabulated-list-put-tag "D" t)
1573 (forward-line 1)))))
1574
1575 (defun package-menu-quick-help ()
1576 "Show short key binding help for package-menu-mode."
1577 (interactive)
1578 (message "n-ext, i-nstall, d-elete, u-nmark, x-ecute, r-efresh, h-elp"))
1579
1580 (define-obsolete-function-alias
1581 'package-menu-view-commentary 'package-menu-describe-package "24.1")
1582
1583 (defun package-menu-get-status ()
1584 (let* ((id (tabulated-list-get-id))
1585 (entry (and id (assq id tabulated-list-entries))))
1586 (if entry
1587 (aref (cadr entry) 2)
1588 "")))
1589
1590 (defun package-menu--find-upgrades ()
1591 (let (installed available upgrades)
1592 ;; Build list of installed/available packages in this buffer.
1593 (dolist (entry tabulated-list-entries)
1594 ;; ENTRY is (PKG-DESC [NAME VERSION STATUS DOC])
1595 (let ((pkg-desc (car entry))
1596 (status (aref (cadr entry) 2)))
1597 (cond ((equal status "installed")
1598 (push pkg-desc installed))
1599 ((member status '("available" "new"))
1600 (push (cons (package-desc-name pkg-desc) pkg-desc)
1601 available)))))
1602 ;; Loop through list of installed packages, finding upgrades.
1603 (dolist (pkg-desc installed)
1604 (let ((avail-pkg (assq (package-desc-name pkg-desc) available)))
1605 (and avail-pkg
1606 (version-list-< (package-desc-version pkg-desc)
1607 (package-desc-version (cdr avail-pkg)))
1608 (push avail-pkg upgrades))))
1609 upgrades))
1610
1611 (defun package-menu-mark-upgrades ()
1612 "Mark all upgradable packages in the Package Menu.
1613 For each installed package with a newer version available, place
1614 an (I)nstall flag on the available version and a (D)elete flag on
1615 the installed version. A subsequent \\[package-menu-execute]
1616 call will upgrade the package."
1617 (interactive)
1618 (unless (derived-mode-p 'package-menu-mode)
1619 (error "The current buffer is not a Package Menu"))
1620 (let ((upgrades (package-menu--find-upgrades)))
1621 (if (null upgrades)
1622 (message "No packages to upgrade.")
1623 (widen)
1624 (save-excursion
1625 (goto-char (point-min))
1626 (while (not (eobp))
1627 (let* ((pkg-desc (tabulated-list-get-id))
1628 (upgrade (cdr (assq (package-desc-name pkg-desc) upgrades))))
1629 (cond ((null upgrade)
1630 (forward-line 1))
1631 ((equal pkg-desc upgrade)
1632 (package-menu-mark-install))
1633 (t
1634 (package-menu-mark-delete))))))
1635 (message "%d package%s marked for upgrading."
1636 (length upgrades)
1637 (if (= (length upgrades) 1) "" "s")))))
1638
1639 (defun package-menu-execute (&optional noquery)
1640 "Perform marked Package Menu actions.
1641 Packages marked for installation are downloaded and installed;
1642 packages marked for deletion are removed.
1643 Optional argument NOQUERY non-nil means do not ask the user to confirm."
1644 (interactive)
1645 (unless (derived-mode-p 'package-menu-mode)
1646 (error "The current buffer is not in Package Menu mode"))
1647 (let (install-list delete-list cmd pkg-desc)
1648 (save-excursion
1649 (goto-char (point-min))
1650 (while (not (eobp))
1651 (setq cmd (char-after))
1652 (unless (eq cmd ?\s)
1653 ;; This is the key PKG-DESC.
1654 (setq pkg-desc (tabulated-list-get-id))
1655 (cond ((eq cmd ?D)
1656 (push pkg-desc delete-list))
1657 ((eq cmd ?I)
1658 (push pkg-desc install-list))))
1659 (forward-line)))
1660 (when install-list
1661 (if (or
1662 noquery
1663 (yes-or-no-p
1664 (if (= (length install-list) 1)
1665 (format "Install package `%s'? "
1666 (package-desc-full-name (car install-list)))
1667 (format "Install these %d packages (%s)? "
1668 (length install-list)
1669 (mapconcat #'package-desc-full-name
1670 install-list ", ")))))
1671 (mapc 'package-install install-list)))
1672 ;; Delete packages, prompting if necessary.
1673 (when delete-list
1674 (if (or
1675 noquery
1676 (yes-or-no-p
1677 (if (= (length delete-list) 1)
1678 (format "Delete package `%s'? "
1679 (package-desc-full-name (car delete-list)))
1680 (format "Delete these %d packages (%s)? "
1681 (length delete-list)
1682 (mapconcat #'package-desc-full-name
1683 delete-list ", ")))))
1684 (dolist (elt delete-list)
1685 (condition-case-unless-debug err
1686 (package-delete elt)
1687 (error (message (cadr err)))))
1688 (error "Aborted")))
1689 (if (or delete-list install-list)
1690 (package-menu--generate t t)
1691 (message "No operations specified."))))
1692
1693 (defun package-menu--version-predicate (A B)
1694 (let ((vA (or (aref (cadr A) 1) '(0)))
1695 (vB (or (aref (cadr B) 1) '(0))))
1696 (if (version-list-= vA vB)
1697 (package-menu--name-predicate A B)
1698 (version-list-< vA vB))))
1699
1700 (defun package-menu--status-predicate (A B)
1701 (let ((sA (aref (cadr A) 2))
1702 (sB (aref (cadr B) 2)))
1703 (cond ((string= sA sB)
1704 (package-menu--name-predicate A B))
1705 ((string= sA "new") t)
1706 ((string= sB "new") nil)
1707 ((string= sA "available") t)
1708 ((string= sB "available") nil)
1709 ((string= sA "installed") t)
1710 ((string= sB "installed") nil)
1711 ((string= sA "held") t)
1712 ((string= sB "held") nil)
1713 ((string= sA "built-in") t)
1714 ((string= sB "built-in") nil)
1715 ((string= sA "obsolete") t)
1716 ((string= sB "obsolete") nil)
1717 (t (string< sA sB)))))
1718
1719 (defun package-menu--description-predicate (A B)
1720 (let ((dA (aref (cadr A) 3))
1721 (dB (aref (cadr B) 3)))
1722 (if (string= dA dB)
1723 (package-menu--name-predicate A B)
1724 (string< dA dB))))
1725
1726 (defun package-menu--name-predicate (A B)
1727 (string< (symbol-name (package-desc-name (car A)))
1728 (symbol-name (package-desc-name (car B)))))
1729
1730 ;;;###autoload
1731 (defun list-packages (&optional no-fetch)
1732 "Display a list of packages.
1733 This first fetches the updated list of packages before
1734 displaying, unless a prefix argument NO-FETCH is specified.
1735 The list is displayed in a buffer named `*Packages*'."
1736 (interactive "P")
1737 (require 'finder-inf nil t)
1738 ;; Initialize the package system if necessary.
1739 (unless package--initialized
1740 (package-initialize t))
1741 (let (old-archives new-packages)
1742 (unless no-fetch
1743 ;; Read the locally-cached archive-contents.
1744 (package-read-all-archive-contents)
1745 (setq old-archives package-archive-contents)
1746 ;; Fetch the remote list of packages.
1747 (package-refresh-contents)
1748 ;; Find which packages are new.
1749 (dolist (elt package-archive-contents)
1750 (unless (assq (car elt) old-archives)
1751 (push (car elt) new-packages))))
1752
1753 ;; Generate the Package Menu.
1754 (let ((buf (get-buffer-create "*Packages*")))
1755 (with-current-buffer buf
1756 (package-menu-mode)
1757 (set (make-local-variable 'package-menu--new-package-list)
1758 new-packages)
1759 (package-menu--generate nil t))
1760 ;; The package menu buffer has keybindings. If the user types
1761 ;; `M-x list-packages', that suggests it should become current.
1762 (switch-to-buffer buf))
1763
1764 (let ((upgrades (package-menu--find-upgrades)))
1765 (if upgrades
1766 (message "%d package%s can be upgraded; type `%s' to mark %s for upgrading."
1767 (length upgrades)
1768 (if (= (length upgrades) 1) "" "s")
1769 (substitute-command-keys "\\[package-menu-mark-upgrades]")
1770 (if (= (length upgrades) 1) "it" "them"))))))
1771
1772 ;;;###autoload
1773 (defalias 'package-list-packages 'list-packages)
1774
1775 ;; Used in finder.el
1776 (defun package-show-package-list (packages)
1777 "Display PACKAGES in a *Packages* buffer.
1778 This is similar to `list-packages', but it does not fetch the
1779 updated list of packages, and it only displays packages with
1780 names in PACKAGES (which should be a list of symbols)."
1781 (require 'finder-inf nil t)
1782 (let ((buf (get-buffer-create "*Packages*")))
1783 (with-current-buffer buf
1784 (package-menu-mode)
1785 (package-menu--generate nil packages))
1786 (switch-to-buffer buf)))
1787
1788 (defun package-list-packages-no-fetch ()
1789 "Display a list of packages.
1790 Does not fetch the updated list of packages before displaying.
1791 The list is displayed in a buffer named `*Packages*'."
1792 (interactive)
1793 (list-packages t))
1794
1795 (provide 'package)
1796
1797 ;;; package.el ends here