annotate lisp/emacs-lisp/package.el @ 110003:336e4a38a76d

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 24 Aug 2010 22:45:30 +0000
parents 77c4a65b9011
children 640cdeb464c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; package.el --- Simple package system for Emacs
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Tom Tromey <tromey@redhat.com>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Created: 10 Mar 2007
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Version: 0.9
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; Keywords: tools
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; any later version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Boston, MA 02110-1301, USA.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;;; Change Log:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; 2 Apr 2007 - now using ChangeLog file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; 15 Mar 2007 - updated documentation
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; 14 Mar 2007 - Changed how obsolete packages are handled
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; 13 Mar 2007 - Wrote package-install-from-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; 12 Mar 2007 - Wrote package-menu mode
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;; Commentary:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; The idea behind package.el is to be able to download packages and
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; install them. Packages are versioned and have versioned
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; dependencies. Furthermore, this supports built-in packages which
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; may or may not be newer than user-specified packages. This makes
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; it possible to upgrade Emacs and automatically disable packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; which have moved from external to core. (Note though that we don't
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; currently register any of these, so this feature does not actually
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;; work.)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; A package is described by its name and version. The distribution
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;; format is either a tar file or a single .el file.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; A tar file should be named "NAME-VERSION.tar". The tar file must
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; unpack into a directory named after the package and version:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;; "NAME-VERSION". It must contain a file named "PACKAGE-pkg.el"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; which consists of a call to define-package. It may also contain a
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; "dir" file and the info files it references.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
55 ;; A .el file is named "NAME-VERSION.el" in the remote archive, but is
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; installed as simply "NAME.el" in a directory named "NAME-VERSION".
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
58 ;; The downloader downloads all dependent packages. By default,
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
59 ;; packages come from the official GNU sources, but others may be
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
60 ;; added by customizing the `package-archives' alist. Packages get
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
61 ;; byte-compiled at install time.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; At activation time we will set up the load-path and the info path,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; and we will load the package's autoloads. If a package's
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; dependencies are not available, we will not activate that package.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 ;; Conceptually a package has multiple state transitions:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ;;
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ;; * Download. Fetching the package from ELPA.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; * Install. Untar the package, or write the .el file, into
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;; ~/.emacs.d/elpa/ directory.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;; * Byte compile. Currently this phase is done during install,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ;; but we may change this.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ;; * Activate. Evaluate the autoloads for the package to make it
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 ;; available to the user.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 ;; * Load. Actually load the package and run some code from it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 ;; Other external functions you may want to use:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 ;;
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 ;; M-x package-list-packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ;; Enters a mode similar to buffer-menu which lets you manage
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 ;; packages. You can choose packages for install (mark with "i",
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 ;; then "x" to execute) or deletion (not implemented yet), and you
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ;; can see what packages are available. This will automatically
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;; fetch the latest list of packages from ELPA.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;;
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;; M-x package-list-packages-no-fetch
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 ;; Like package-list-packages, but does not automatically fetch the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; new list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;;
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ;; M-x package-install-from-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; Install a package consisting of a single .el file that appears
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 ;; in the current buffer. This only works for packages which
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;; define a Version header properly; package.el also supports the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 ;; extension headers Package-Version (in case Version is an RCS id
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 ;; or similar), and Package-Requires (if the package requires other
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 ;; packages).
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ;;
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;; M-x package-install-file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;; Install a package from the indicated file. The package can be
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;; either a tar file or a .el file. A tar file must contain an
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; appropriately-named "-pkg.el" file; a .el file must be properly
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 ;; formatted as with package-install-from-buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 ;;; Thanks:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 ;;; (sorted by sort-lines):
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 ;; Jim Blandy <jimb@red-bean.com>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 ;; Karl Fogel <kfogel@red-bean.com>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 ;; Kevin Ryde <user42@zip.com.au>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 ;; Lawrence Mitchell
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 ;; Michael Olson <mwolson@member.fsf.org>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 ;; Sebastian Tennant <sebyte@smolny.plus.com>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 ;; Stefan Monnier <monnier@iro.umontreal.ca>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ;; Phil Hagelberg <phil@hagelb.org>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ;;; ToDo:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 ;; - putting info dirs at the start of the info path means
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 ;; users see a weird ordering of categories. OTOH we want to
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 ;; override later entries. maybe emacs needs to enforce
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ;; the standard layout?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 ;; - put bytecode in a separate directory tree
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 ;; - perhaps give users a way to recompile their bytecode
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 ;; or do it automatically when emacs changes
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 ;; - give users a way to know whether a package is installed ok
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 ;; - give users a way to view a package's documentation when it
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; only appears in the .el
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 ;; - use/extend checkdoc so people can tell if their package will work
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ;; - "installed" instead of a blank in the status column
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 ;; - tramp needs its files to be compiled in a certain order.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; how to handle this? fix tramp?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 ;; - on emacs 21 we don't kill the -autoloads.el buffer. what about 22?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 ;; - maybe we need separate .elc directories for various emacs versions
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 ;; and also emacs-vs-xemacs. That way conditional compilation can
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 ;; work. But would this break anything?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 ;; - should store the package's keywords in archive-contents, then
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 ;; let the users filter the package-menu by keyword. See
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 ;; finder-by-keyword. (We could also let people view the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 ;; Commentary, but it isn't clear how useful this is.)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 ;; - William Xu suggests being able to open a package file without
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;; installing it
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;; - Interface with desktop.el so that restarting after an install
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 ;; works properly
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 ;; - Implement M-x package-upgrade, to upgrade any/all existing packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 ;; - Use hierarchical layout. PKG/etc PKG/lisp PKG/info
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 ;; ... except maybe lisp?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 ;; - It may be nice to have a macro that expands to the package's
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 ;; private data dir, aka ".../etc". Or, maybe data-directory
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 ;; needs to be a list (though this would be less nice)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 ;; a few packages want this, eg sokoban
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 ;; - package menu needs:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 ;; ability to know which packages are built-in & thus not deletable
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; it can sometimes print odd results, like 0.3 available but 0.4 active
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 ;; why is that?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 ;; - Allow multiple versions on the server...?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 ;; [ why bother? ]
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 ;; - Don't install a package which will invalidate dependencies overall
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 ;; - Allow something like (or (>= emacs 21.0) (>= xemacs 21.5))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 ;; [ currently thinking, why bother.. KISS ]
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 ;; - Allow optional package dependencies
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 ;; then if we require 'bbdb', bbdb-specific lisp in lisp/bbdb
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 ;; and just don't compile to add to load path ...?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;; - Have a list of archive URLs? [ maybe there's no point ]
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 ;; - David Kastrup pointed out on the xemacs list that for GPL it
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 ;; is friendlier to ship the source tree. We could "support" that
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 ;; by just having a "src" subdir in the package. This isn't ideal
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 ;; but it probably is not worth trying to support random source
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 ;; tree layouts, build schemes, etc.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 ;; - Our treatment of the info path is somewhat bogus
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;; - perhaps have an "unstable" tree in ELPA as well as a stable one
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 ;;; Code:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (defgroup package nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 "Manager for Emacs Lisp packages."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 :group 'applications
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (defcustom package-enable-at-startup t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 "Whether to activate installed packages when Emacs starts.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 If non-nil, packages are activated after reading the init file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 and before `after-init-hook'. Activation is not done if
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 `user-init-file' is nil (e.g. Emacs was started with \"-q\").
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 Even if the value is nil, you can type \\[package-initialize] to
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 activate the package system at any time."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 :type 'boolean
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (defcustom package-load-list '(all)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 "List of packages for `package-initialize' to load.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 Each element in this list should be a list (NAME VERSION), or the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 symbol `all'. The symbol `all' says to load the latest installed
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 versions of all packages not specified by other elements.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 For an element (NAME VERSION), NAME is a package name (a symbol).
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 VERSION should be t, a string, or nil.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 If VERSION is t, all versions are loaded, though obsolete ones
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 will be put in `package-obsolete-alist' and not activated.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 If VERSION is a string, only that version is ever loaded.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 Any other version, even if newer, is silently ignored.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 Hence, the package is \"held\" at that version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 If VERSION is nil, the package is not loaded (it is \"disabled\")."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 :type '(repeat symbol)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
209 :risky t
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (defvar Info-directory-list)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (declare-function info-initialize "info" ())
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (declare-function url-http-parse-response "url-http" ())
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (declare-function lm-header "lisp-mnt" (header))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (declare-function lm-commentary "lisp-mnt" (&optional file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (declare-function dired-delete-file "dired" (file &optional recursive trash))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
220 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/"))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
221 "An alist of archives from which to fetch.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
222 The default value points to the GNU Emacs package repository.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
223 Each element has the form (ID . URL), where ID is an identifier
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
224 string for an archive and URL is a http: URL (a string)."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
225 :type '(alist :key-type (string :tag "Archive name")
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
226 :value-type (string :tag "Archive URL"))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
227 :risky t
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
228 :group 'package
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
229 :version "24.1")
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (defconst package-archive-version 1
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 "Version number of the package archive understood by this file.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 Lower version numbers than this will probably be understood as well.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (defconst package-el-version "1.0"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 "Version of package.el.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;; We don't prime the cache since it tends to get out of date.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 (defvar package-archive-contents nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 "Cache of the contents of the Emacs Lisp Package Archive.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 This is an alist mapping package names (symbols) to package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 descriptor vectors. These are like the vectors for `package-alist'
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
243 but have extra entries: one which is 'tar for tar packages and
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
244 'single for single-file packages, and one which is the name of
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
245 the archive from which it came.")
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
246 (put 'package-archive-contents 'risky-local-variable t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (defcustom package-user-dir (locate-user-emacs-file "elpa")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 "Directory containing the user's Emacs Lisp packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 The directory name should be absolute.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 Apart from this directory, Emacs also looks for system-wide
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 packages in `package-directory-list'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 :type 'directory
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
254 :risky t
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (defcustom package-directory-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 ;; Defaults are subdirs named "elpa" in the site-lisp dirs.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (let (result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (dolist (f load-path)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (if (equal (file-name-nondirectory f) "site-lisp")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (push (expand-file-name "elpa" f) result)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (nreverse result))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 "List of additional directories containing Emacs Lisp packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 Each directory name should be absolute.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 These directories contain packages intended for system-wide; in
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 contrast, `package-user-dir' contains packages for personal use."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 :type '(repeat directory)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
271 :risky t
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (defconst package--builtins-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;; We use package-version split here to make sure to pick up the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 ;; minor version.
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
278 `((emacs . [,(version-to-list emacs-version) nil
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 "GNU Emacs"])
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
280 (package . [,(version-to-list package-el-version)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 nil "Simple package system for GNU Emacs"]))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 "Packages which are always built-in.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (defvar package--builtins
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (delq nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (append
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 package--builtins-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (if (>= emacs-major-version 22)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 ;; FIXME: emacs 22 includes tramp, rcirc, maybe
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 ;; other things...
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
291 '((erc . [(5 2) nil "Internet Relay Chat client"])
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 ;; The external URL is version 1.15, so make sure the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 ;; built-in one looks newer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (url . [(1 16) nil "URL handling libary"])))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (if (>= emacs-major-version 23)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 '(;; Strangely, nxml-version is missing in Emacs 23.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 ;; We pick the merge date as the version.
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
298 (nxml . [(20071123) nil "Major mode for XML documents"])
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
299 (bubbles . [(0 5) nil "A puzzle game"])))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 "Alist of all built-in packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 Maps the package name to a vector [VERSION REQS DOCSTRING].")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
302 (put 'package--builtins 'risky-local-variable t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (defvar package-alist package--builtins
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 "Alist of all packages available for activation.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 This maps the package name to a vector [VERSION REQS DOCSTRING].
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 The value is generated by `package-load-descriptor', usually
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 called via `package-initialize'. For user customizations of
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 which packages to load/activate, see `package-load-list'.")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
311 (put 'package-archive-contents 'risky-local-variable t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (defvar package-activated-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (mapcar #'car package-alist)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 "List of the names of currently activated packages.")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
316 (put 'package-activated-list 'risky-local-variable t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (defvar package-obsolete-alist nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 "Representation of obsolete packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 Like `package-alist', but maps package name to a second alist.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 The inner alist is keyed by version.")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
322 (put 'package-obsolete-alist 'risky-local-variable t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (defconst package-subdirectory-regexp
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 "Regular expression matching the name of a package subdirectory.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 The first subexpression is the package name.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 The second subexpression is the version string.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (defun package-version-join (l)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 "Turn a list of version numbers into a version string."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (mapconcat 'int-to-string l "."))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (defun package-strip-version (dirname)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 "Strip the version from a combined package name and version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 E.g., if given \"quux-23.0\", will return \"quux\""
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (if (string-match package-subdirectory-regexp dirname)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (match-string 1 dirname)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (defun package-load-descriptor (dir package)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
341 "Load the description file in directory DIR for package PACKAGE."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
342 (let* ((pkg-dir (expand-file-name package dir))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
343 (pkg-file (expand-file-name
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
344 (concat (package-strip-version package) "-pkg")
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
345 pkg-dir)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
346 (when (and (file-directory-p pkg-dir)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
347 (file-exists-p (concat pkg-file ".el")))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
348 (load pkg-file nil t))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (defun package-load-all-descriptors ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 "Load descriptors for installed Emacs Lisp packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 This looks for package subdirectories in `package-user-dir' and
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 `package-directory-list'. The variable `package-load-list'
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 controls which package subdirectories may be loaded.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 In each valid package subdirectory, this function loads the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 description file containing a call to `define-package', which
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 updates `package-alist' and `package-obsolete-alist'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (let ((all (memq 'all package-load-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 name version force)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (dolist (dir (cons package-user-dir package-directory-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (when (file-directory-p dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (dolist (subdir (directory-files dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (when (and (file-directory-p (expand-file-name subdir dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (string-match package-subdirectory-regexp subdir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (setq name (intern (match-string 1 subdir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 version (match-string 2 subdir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 force (assq name package-load-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (when (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ((null force)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 all) ; not in package-load-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ((null (setq force (cadr force)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 nil) ; disabled
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 ((eq force t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ((stringp force) ; held
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
377 (version-list-= (version-to-list version)
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
378 (version-to-list force)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (error "Invalid element in `package-load-list'")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (package-load-descriptor dir subdir))))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (defsubst package-desc-vers (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 "Extract version from a package description vector."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (aref desc 0))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (defsubst package-desc-reqs (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 "Extract requirements from a package description vector."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (aref desc 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (defsubst package-desc-doc (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 "Extract doc string from a package description vector."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (aref desc 2))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (defsubst package-desc-kind (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 "Extract the kind of download from an archive package description vector."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (aref desc 3))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
399 (defun package--dir (name version-string)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
400 (let* ((subdir (concat name "-" version-string))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (dir-list (cons package-user-dir package-directory-list))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
402 pkg-dir)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (while dir-list
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
404 (let ((subdir-full (expand-file-name subdir (car dir-list))))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
405 (if (file-directory-p subdir-full)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
406 (setq pkg-dir subdir-full
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
407 dir-list nil)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (setq dir-list (cdr dir-list)))))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
409 pkg-dir))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
410
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
411 (defun package-activate-1 (package pkg-vec)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
412 (let* ((name (symbol-name package))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
413 (version-str (package-version-join (package-desc-vers pkg-vec)))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
414 (pkg-dir (package--dir name version-str)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (unless pkg-dir
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (error "Internal error: could not find directory for %s-%s"
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
417 name version-str))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
418 ;; Add info node.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (if (file-exists-p (expand-file-name "dir" pkg-dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; FIXME: not the friendliest, but simple.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (require 'info)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (info-initialize)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (setq Info-directory-list (cons pkg-dir Info-directory-list))))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
425 ;; Add to load path, add autoloads, and activate the package.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (setq load-path (cons pkg-dir load-path))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
427 (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (setq package-activated-list (cons package package-activated-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;; Don't return nil.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 t))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (defun package--built-in (package version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 "Return true if the package is built-in to Emacs."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (let ((elt (assq package package--builtins)))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
435 (and elt (version-list-= (package-desc-vers (cdr elt)) version))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 ;; FIXME: return a reason instead?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (defun package-activate (package version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 "Activate a package, and recursively activate its dependencies.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 Return nil if the package could not be activated."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 ;; Assume the user knows what he is doing -- go ahead and activate a
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 ;; newer version of a package if an older one has already been
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 ;; activated. This is not ideal; we'd at least need to check to see
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 ;; if the package has actually been loaded, and not merely
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 ;; activated. However, don't try to activate 'emacs', as that makes
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 ;; no sense.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (unless (eq package 'emacs)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (let* ((pkg-desc (assq package package-alist))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (this-version (package-desc-vers (cdr pkg-desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (req-list (package-desc-reqs (cdr pkg-desc)))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
451 ;; If the package was never activated, do it now.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (keep-going (or (not (memq package package-activated-list))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
453 (version-list-< version this-version))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (while (and req-list keep-going)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (let* ((req (car req-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (req-name (car req))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (req-version (cadr req)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (or (package-activate req-name req-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (setq keep-going nil)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (setq req-list (cdr req-list)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (if keep-going
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (package-activate-1 package (cdr pkg-desc))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 ;; We get here if a dependency failed to activate -- but we
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 ;; can also get here if the requested package was already
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;; activated. Return non-nil in the latter case.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (and (memq package package-activated-list)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
467 (version-list-<= version this-version))))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (defun package-mark-obsolete (package pkg-vec)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 "Put package on the obsolete list, if not already there."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (let ((elt (assq package package-obsolete-alist)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (if elt
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 ;; If this obsolete version does not exist in the list, update
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 ;; it the list.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (unless (assoc (package-desc-vers pkg-vec) (cdr elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (setcdr elt (cons (cons (package-desc-vers pkg-vec) pkg-vec)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (cdr elt))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 ;; Make a new association.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (setq package-obsolete-alist
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (cons (cons package (list (cons (package-desc-vers pkg-vec)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 pkg-vec)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 package-obsolete-alist)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 ;; (define-package "emacs" "21.4.1" "GNU Emacs core package.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 ;; (define-package "erc" "5.1" "ERC - irc client" '((emacs "21.0")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (defun define-package (name-str version-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 &optional docstring requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 "Define a new package.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 NAME is the name of the package, a string.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 VERSION-STRING is the version of the package, a dotted sequence
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 of integers.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 DOCSTRING is the optional description.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 REQUIREMENTS is a list of requirements on other packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 Each requirement is of the form (OTHER-PACKAGE \"VERSION\")."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (let* ((name (intern name-str))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (pkg-desc (assq name package-alist))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
497 (new-version (version-to-list version-string))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (new-pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (cons name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (vector new-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
504 (version-to-list (car (cdr elt)))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 docstring))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 ;; Only redefine a package if the redefinition is newer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 (if (or (not pkg-desc)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
509 (version-list-< (package-desc-vers (cdr pkg-desc))
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
510 new-version))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 (when pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 ;; Remove old package and declare it obsolete.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 (setq package-alist (delq pkg-desc package-alist))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 (package-mark-obsolete (car pkg-desc) (cdr pkg-desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 ;; Add package to the alist.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 (setq package-alist (cons new-pkg-desc package-alist)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;; You can have two packages with the same version, for instance
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 ;; one in the system package directory and one in your private
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 ;; directory. We just let the first one win.
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
521 (unless (version-list-= new-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
522 (package-desc-vers (cdr pkg-desc)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ;; The package is born obsolete.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 (package-mark-obsolete (car new-pkg-desc) (cdr new-pkg-desc))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 ;; From Emacs 22.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 (defun package-autoload-ensure-default-file (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 "Make sure that the autoload file FILE exists and if not create it."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 (unless (file-exists-p file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 (write-region
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 (concat ";;; " (file-name-nondirectory file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 " --- automatically extracted autoloads\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ";;\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ";;; Code:\n\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 " \n;; Local Variables:\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 ";; version-control: never\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 ";; no-byte-compile: t\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 ";; no-update-autoloads: t\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 ";; End:\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 ";;; " (file-name-nondirectory file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 " ends here\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 nil file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 (defun package-generate-autoloads (name pkg-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 (let* ((auto-name (concat name "-autoloads.el"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 (ignore-name (concat name "-pkg.el"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (generated-autoload-file (expand-file-name auto-name pkg-dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 (version-control 'never))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 (require 'autoload)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (unless (fboundp 'autoload-ensure-default-file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 (package-autoload-ensure-default-file generated-autoload-file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (update-directory-autoloads pkg-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 (defun package-untar-buffer ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 "Untar the current buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 This uses `tar-untar-buffer' if it is available.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 Otherwise it uses an external `tar' program.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 `default-directory' should be set by the caller."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 (require 'tar-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 (if (fboundp 'tar-untar-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 ;; tar-mode messes with narrowing, so we just let it have the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 ;; whole buffer to play with.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 (delete-region (point-min) (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (tar-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (tar-untar-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 ;; FIXME: check the result.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 (call-process-region (point) (point-max) "tar" nil '(nil nil) nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 "xf" "-")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 (defun package-unpack (name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 (let ((pkg-dir (expand-file-name (concat (symbol-name name) "-" version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 package-user-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 ;; Be careful!!
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 (make-directory package-user-dir t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 (if (file-directory-p pkg-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 (mapc (lambda (file) nil) ; 'delete-file -- FIXME: when we're
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 ; more confident
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 (directory-files pkg-dir t "^[^.]")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (let* ((default-directory (file-name-as-directory package-user-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 (package-untar-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 (package-generate-autoloads (symbol-name name) pkg-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 (let ((load-path (cons pkg-dir load-path)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 (byte-recompile-directory pkg-dir 0 t)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
587 (defun package--write-file-no-coding (file-name excl)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
588 (let ((buffer-file-coding-system 'no-conversion))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
589 (write-region (point-min) (point-max) file-name nil nil nil excl)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
590
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 (defun package-unpack-single (file-name version desc requires)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 "Install the contents of the current buffer as a package."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 ;; Special case "package".
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (if (string= file-name "package")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
595 (package--write-file-no-coding
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
596 (expand-file-name (concat file-name ".el") package-user-dir)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
597 nil)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 (let* ((pkg-dir (expand-file-name (concat file-name "-" version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 package-user-dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 (el-file (expand-file-name (concat file-name ".el") pkg-dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 (make-directory pkg-dir t)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
603 (package--write-file-no-coding el-file 'excl)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (let ((print-level nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 (print-length nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (write-region
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 (concat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (prin1-to-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 (list 'define-package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 file-name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 (list 'quote
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 ;; Turn version lists into string form.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 (list (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (package-version-join (car (cdr elt)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 requires))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 "\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 pkg-file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 nil nil nil 'excl))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 (package-generate-autoloads file-name pkg-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (let ((load-path (cons pkg-dir load-path)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 (byte-recompile-directory pkg-dir 0 t)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 (defun package-handle-response ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 "Handle the response from the server.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 Parse the HTTP response and throw if an error occurred.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 The url package seems to require extra processing for this.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 This should be called in a `save-excursion', in the download buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 It will move point to somewhere in the headers."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 ;; We assume HTTP here.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (require 'url-http)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 (let ((response (url-http-parse-response)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 (when (or (< response 200) (>= response 300))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (display-buffer (current-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 (error "Error during download request:%s"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (buffer-substring-no-properties (point) (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (end-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (point)))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (defun package-download-single (name version desc requires)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 "Download and install a single-file package."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 (let ((buffer (url-retrieve-synchronously
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
647 (concat (package-archive-url name)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 (symbol-name name) "-" version ".el"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 (with-current-buffer buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (delete-region (point-min) (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 (package-unpack-single (symbol-name name) version desc requires)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (kill-buffer buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (defun package-download-tar (name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 "Download and install a tar package."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (let ((tar-buffer (url-retrieve-synchronously
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
660 (concat (package-archive-url name)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (symbol-name name) "-" version ".tar"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 (with-current-buffer tar-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 (package-unpack name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 (kill-buffer tar-buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
669 (defun package-installed-p (package &optional min-version)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (let ((pkg-desc (assq package package-alist)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 (and pkg-desc
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
672 (version-list-<= min-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
673 (package-desc-vers (cdr pkg-desc))))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 (defun package-compute-transaction (result requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (dolist (elt requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (let* ((next-pkg (car elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 (next-version (cadr elt)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (unless (package-installed-p next-pkg next-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 ;; A package is required, but not installed. It might also be
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 ;; blocked via `package-load-list'.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 (let ((pkg-desc (assq next-pkg package-archive-contents))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 hold)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 (when (setq hold (assq next-pkg package-load-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (setq hold (cadr hold))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (cond ((eq hold nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (error "Required package '%s' is disabled"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 (symbol-name next-pkg)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 ((null (stringp hold))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 (error "Invalid element in `package-load-list'"))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
691 ((version-list-< (version-to-list hold) next-version)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (error "Package '%s' held at version %s, \
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 but version %s required"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 (symbol-name next-pkg) hold
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (package-version-join next-version)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (unless pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 (error "Package '%s' is not available for installation"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (symbol-name next-pkg)))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
699 (unless (version-list-<= next-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
700 (package-desc-vers (cdr pkg-desc)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 (error
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 "Need package '%s' with version %s, but only %s is available"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 (symbol-name next-pkg) (package-version-join next-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 (package-version-join (package-desc-vers (cdr pkg-desc)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 ;; Only add to the transaction if we don't already have it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (unless (memq next-pkg result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 (setq result (cons next-pkg result)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 (setq result
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 (package-compute-transaction result
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 (package-desc-reqs
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 (cdr pkg-desc))))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (defun package-read-from-string (str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 "Read a Lisp expression from STR.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 Signal an error if the entire string was not used."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (let* ((read-data (read-from-string str))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (more-left
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 (condition-case nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 ;; The call to `ignore' suppresses a compiler warning.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 (progn (ignore (read-from-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 (substring str (cdr read-data))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (end-of-file nil))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 (if more-left
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (error "Can't read whole string")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (car read-data))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 (defun package--read-archive-file (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 "Re-read archive file FILE, if it exists.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 Will return the data from the file, or nil if the file does not exist.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 Will throw an error if the archive version is too new."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (let ((filename (expand-file-name file package-user-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 (if (file-exists-p filename)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 (with-temp-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (insert-file-contents-literally filename)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (let ((contents (package-read-from-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (buffer-substring-no-properties (point-min)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (point-max)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 (if (> (car contents) package-archive-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 (error "Package archive version %d is greater than %d - upgrade package.el"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 (car contents) package-archive-version))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 (cdr contents))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
745 (defun package-read-all-archive-contents ()
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 "Re-read `archive-contents' and `builtin-packages', if they exist.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 Set `package-archive-contents' and `package--builtins' if successful.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748 Throw an error if the archive version is too new."
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
749 (dolist (archive package-archives)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
750 (package-read-archive-contents (car archive)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
751 (let ((builtins (package--read-archive-file "builtin-packages")))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (if builtins
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 ;; Version 1 of 'builtin-packages' is a list where the car is
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 ;; a split emacs version and the cdr is an alist suitable for
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 ;; package--builtins.
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
756 (let ((our-version (version-to-list emacs-version))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 (result package--builtins-base))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (setq package--builtins
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 (dolist (elt builtins result)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
760 (if (version-list-<= (car elt) our-version)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 (setq result (append (cdr elt) result)))))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
763 (defun package-read-archive-contents (archive)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
764 "Re-read `archive-contents' and `builtin-packages' for ARCHIVE.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
765 If successful, set `package-archive-contents' and `package--builtins'.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
766 If the archive version is too new, signal an error."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
767 (let ((archive-contents (package--read-archive-file
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
768 (concat "archives/" archive
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
769 "/archive-contents"))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
770 (if archive-contents
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
771 ;; Version 1 of 'archive-contents' is identical to our
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
772 ;; internal representation.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
773 ;; TODO: merge archive lists
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
774 (dolist (package archive-contents)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
775 (package--add-to-archive-contents package archive)))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
776
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
777 (defun package--add-to-archive-contents (package archive)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
778 "Add the PACKAGE from the given ARCHIVE if necessary.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
779 Also, add the originating archive to the end of the package vector."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
780 (let* ((name (car package))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
781 (version (aref (cdr package) 0))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
782 (entry (cons (car package)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
783 (vconcat (cdr package) (vector archive))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
784 (existing-package (cdr (assq name package-archive-contents))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
785 (when (or (not existing-package)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
786 (version-list-< (aref existing-package 0) version))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
787 (add-to-list 'package-archive-contents entry))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
788
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 (defun package-download-transaction (transaction)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 "Download and install all the packages in the given transaction."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791 (dolist (elt transaction)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (let* ((desc (cdr (assq elt package-archive-contents)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 ;; As an exception, if package is "held" in
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 ;; `package-load-list', download the held version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 (hold (cadr (assq elt package-load-list)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 (v-string (or (and (stringp hold) hold)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 (package-version-join (package-desc-vers desc))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 (kind (package-desc-kind desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 ((eq kind 'tar)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 (package-download-tar elt v-string))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 ((eq kind 'single)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 (package-download-single elt v-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (package-desc-doc desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 (package-desc-reqs desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807 (error "Unknown package kind: %s" (symbol-name kind)))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 (defun package-install (name)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 "Install the package named NAME.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 Interactively, prompt for the package name.
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
813 The package is found on one of the archives in `package-archives'."
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 (interactive
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
815 (list (intern (completing-read "Install package: "
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
816 (mapcar (lambda (elt)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
817 (cons (symbol-name (car elt))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
818 nil))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
819 package-archive-contents)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
820 nil t))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
821 (let ((pkg-desc (assq name package-archive-contents)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
822 (unless pkg-desc
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
823 (error "Package '%s' is not available for installation"
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 (symbol-name name)))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
825 (package-download-transaction
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
826 (package-compute-transaction (list name)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
827 (package-desc-reqs (cdr pkg-desc)))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
828 ;; Try to activate it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 (package-initialize))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
830
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
831 (defun package-strip-rcs-id (v-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 "Strip RCS version ID from the version string.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
833 If the result looks like a dotted numeric version, return it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
834 Otherwise return nil."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 (if v-str
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 (if (string-match "^[ \t]*[$]Revision:[ \t]\([0-9.]+\)[ \t]*[$]$" v-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
837 (match-string 1 v-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
838 (if (string-match "^[0-9.]*$" v-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
839 v-str))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
840
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841 (defun package-buffer-info ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
842 "Return a vector of information about the package in the current buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
843 The vector looks like [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY]
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 FILENAME is the file name, a string. It does not have the \".el\" extension.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
845 REQUIRES is a requires list, or nil.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
846 DESCRIPTION is the package description (a string).
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 VERSION is the version, a string.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
848 COMMENTARY is the commentary section, a string, or nil if none.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
849 Throws an exception if the buffer does not contain a conforming package.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 If there is a package, narrows the buffer to the file's boundaries.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
851 May narrow buffer or move point even on failure."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 (if (re-search-forward "^;;; \\([^ ]*\\)\\.el --- \\(.*\\)$" nil t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
854 (let ((file-name (match-string 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855 (desc (match-string 2))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856 (start (progn (beginning-of-line) (point))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 (if (search-forward (concat ";;; " file-name ".el ends here"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
859 ;; Try to include a trailing newline.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 (forward-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861 (narrow-to-region start (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 (require 'lisp-mnt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 ;; Use some headers we've invented to drive the process.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
864 (let* ((requires-str (lm-header "package-requires"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 (requires (if requires-str
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 (package-read-from-string requires-str)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 ;; Prefer Package-Version, because if it is
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
868 ;; defined the package author probably wants us
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 ;; to use it. Otherwise try Version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 (pkg-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
871 (or (package-strip-rcs-id (lm-header "package-version"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
872 (package-strip-rcs-id (lm-header "version"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 (commentary (lm-commentary)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 (unless pkg-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 (error
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876 "Package does not define a usable \"Version\" or \"Package-Version\" header"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
877 ;; Turn string version numbers into list form.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 (setq requires
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
879 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
880 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
882 (version-to-list (car (cdr elt)))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 requires))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 (set-text-properties 0 (length file-name) nil file-name)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 (set-text-properties 0 (length pkg-version) nil pkg-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886 (set-text-properties 0 (length desc) nil desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 (vector file-name requires desc pkg-version commentary)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 (error "Package missing a terminating comment")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
889 (error "No starting comment for package")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
890
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 (defun package-tar-file-info (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 "Find package information for a tar file.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
893 FILE is the name of the tar file to examine.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 The return result is a vector like `package-buffer-info'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 (unless (string-match "^\\(.+\\)-\\([0-9.]+\\)\\.tar$" file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 (error "`%s' doesn't have a package-ish name" file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 (let* ((pkg-name (file-name-nondirectory (match-string-no-properties 1 file)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 (pkg-version (match-string-no-properties 2 file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 ;; Extract the package descriptor.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
900 (pkg-def-contents (shell-command-to-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 ;; Requires GNU tar.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902 (concat "tar -xOf " file " "
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 pkg-name "-" pkg-version "/"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 pkg-name "-pkg.el")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
905 (pkg-def-parsed (package-read-from-string pkg-def-contents)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906 (unless (eq (car pkg-def-parsed) 'define-package)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 (error "%s-pkg.el doesn't contain `define-package' sexp" pkg-name))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 (let ((name-str (nth 1 pkg-def-parsed))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 (version-string (nth 2 pkg-def-parsed))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910 (docstring (nth 3 pkg-def-parsed))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 (requires (nth 4 pkg-def-parsed))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 (readme (shell-command-to-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
914 ;; Requires GNU tar.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915 (concat "tar -xOf " file " "
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 pkg-name "-" pkg-version "/README"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
917 (unless (equal pkg-version version-string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 (error "Inconsistent versions!"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919 (unless (equal pkg-name name-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 (error "Inconsistent names!"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 ;; Kind of a hack.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 (if (string-match ": Not found in archive" readme)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 (setq readme nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 ;; Turn string version numbers into list form.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
925 (if (eq (car requires) 'quote)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
926 (setq requires (car (cdr requires))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 (setq requires
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
929 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
930 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
931 (version-to-list (car (cdr elt)))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932 requires))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 (vector pkg-name requires docstring version-string readme))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
935 (defun package-install-buffer-internal (pkg-info type)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (save-restriction
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
938 (let* ((file-name (aref pkg-info 0))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 (requires (aref pkg-info 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
940 (desc (if (string= (aref pkg-info 2) "")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 "No description available."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 (aref pkg-info 2)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943 (pkg-version (aref pkg-info 3)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
944 ;; Download and install the dependencies.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
945 (let ((transaction (package-compute-transaction nil requires)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 (package-download-transaction transaction))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 ;; Install the package itself.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
948 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 ((eq type 'single)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
950 (package-unpack-single file-name pkg-version desc requires))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
951 ((eq type 'tar)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 (package-unpack (intern file-name) pkg-version))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 (error "Unknown type: %s" (symbol-name type))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 ;; Try to activate it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 (package-initialize)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (defun package-install-from-buffer ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 "Install a package from the current buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 The package is assumed to be a single .el file which
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 follows the elisp comment guidelines; see
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 info node `(elisp)Library Headers'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965 (package-install-buffer-internal (package-buffer-info) 'single))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 (defun package-install-file (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969 "Install a package from a file.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970 The file can either be a tar file or an Emacs Lisp file."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
971 (interactive "fPackage file name: ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 (with-temp-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 (insert-file-contents-literally file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 ((string-match "\\.el$" file) (package-install-from-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 ((string-match "\\.tar$" file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
977 (package-install-buffer-internal (package-tar-file-info file) 'tar))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978 (t (error "Unrecognized extension `%s'" (file-name-extension file))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
979
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
980 (defun package-delete (name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
981 (require 'dired) ; for dired-delete-file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
982 (dired-delete-file (expand-file-name (concat name "-" version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
983 package-user-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
984 ;; FIXME: query user?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
985 'always))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
986
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
987 (defun package-archive-url (name)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
988 "Return the archive containing the package NAME."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
989 (let ((desc (cdr (assq (intern-soft name) package-archive-contents))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
990 (cdr (assoc (aref desc (- (length desc) 1)) package-archives))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
991
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
992 (defun package--download-one-archive (archive file)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
993 "Download an archive file FILE from ARCHIVE, and cache it locally."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
994 (let* ((archive-name (car archive))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
995 (archive-url (cdr archive))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
996 (dir (expand-file-name "archives" package-user-dir))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
997 (dir (expand-file-name archive-name dir))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
998 (buffer (url-retrieve-synchronously (concat archive-url file))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
999 (with-current-buffer buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1000 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1001 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1002 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1003 (delete-region (point-min) (point))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1004 (make-directory dir t)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1005 (setq buffer-file-name (expand-file-name file dir))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1006 (let ((version-control 'never))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1007 (save-buffer)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1008 (kill-buffer buffer)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010 (defun package-refresh-contents ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1011 "Download the ELPA archive description if needed.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1012 Invoking this will ensure that Emacs knows about the latest versions
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1013 of all packages. This will let Emacs make them available for
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1014 download."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1015 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1016 (unless (file-exists-p package-user-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1017 (make-directory package-user-dir t))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1018 (dolist (archive package-archives)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1019 (package--download-one-archive archive "archive-contents"))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1020 (package-read-all-archive-contents))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1021
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1022 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1023 (defun package-initialize ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1024 "Load Emacs Lisp packages, and activate them.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1025 The variable `package-load-list' controls which packages to load."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1026 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1027 (setq package-obsolete-alist nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1028 (package-load-all-descriptors)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1029 (package-read-all-archive-contents)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1030 ;; Try to activate all our packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1031 (mapc (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1032 (package-activate (car elt) (package-desc-vers (cdr elt))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1033 package-alist))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1034
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1035
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1036 ;;;; Package description buffer.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1037
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1038 ;;;###autoload
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1039 (defun describe-package (package)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1040 "Display the full documentation of PACKAGE (a symbol)."
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1041 (interactive
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1042 (let* ((packages (append (mapcar 'car package-alist)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1043 (mapcar 'car package-archive-contents)))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1044 (guess (function-called-at-point))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1045 val)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1046 (unless (memq guess packages)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1047 (setq guess nil))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1048 (setq packages (mapcar 'symbol-name packages))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1049 (setq val
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1050 (completing-read (if guess
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1051 (format "Describe package (default %s): "
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1052 guess)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1053 "Describe package: ")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1054 packages nil t nil nil guess))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1055 (list (if (equal val "")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1056 guess
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1057 (intern val)))))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1058 (if (or (null package) (null (symbolp package)))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1059 (message "You did not specify a package")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1060 (help-setup-xref (list #'describe-package package)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1061 (called-interactively-p 'interactive))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1062 (with-help-window (help-buffer)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1063 (with-current-buffer standard-output
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1064 (describe-package-1 package)))))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1065
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1066 (defun describe-package-1 (package)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1067 (let ((desc (cdr (assq package package-alist)))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1068 reqs version installable)
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1069 (prin1 package)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1070 (princ " is ")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1071 (cond
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1072 (desc
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1073 ;; This package is loaded (i.e. in `package-alist').
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1074 (let (pkg-dir)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1075 (setq version (package-version-join (package-desc-vers desc)))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1076 (if (assq package package--builtins)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1077 (princ "a built-in package.\n\n")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1078 (setq pkg-dir (package--dir (symbol-name package) version))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1079 (if pkg-dir
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1080 (progn
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1081 (insert "a package installed in `")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1082 (help-insert-xref-button (file-name-as-directory pkg-dir)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1083 'help-package-def pkg-dir)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1084 (insert "'.\n\n"))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1085 ;; This normally does not happen.
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1086 (insert "a deleted package.\n\n")
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1087 (setq version nil)))))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1088 (t
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1089 ;; An uninstalled package.
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1090 (setq desc (cdr (assq package package-archive-contents))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1091 version (package-version-join (package-desc-vers desc))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1092 installable t)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1093 (insert "an installable package.\n\n")))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1094 (if version
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1095 (insert " Version: " version "\n"))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1096 (setq reqs (package-desc-reqs desc))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1097 (when reqs
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1098 (insert " Requires: ")
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1099 (let ((first t)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1100 name vers text)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1101 (dolist (req reqs)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1102 (setq name (car req)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1103 vers (cadr req)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1104 text (format "%s-%s" (symbol-name name)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1105 (package-version-join vers)))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1106 (cond (first (setq first nil))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1107 ((>= (+ 2 (current-column) (length text))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1108 (window-width))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1109 (insert ",\n "))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1110 (t (insert ", ")))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1111 (help-insert-xref-button text 'help-package name))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1112 (insert "\n")))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1113 (insert " Description: " (package-desc-doc desc) "\n")
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1114 ;; Todo: button for uninstalling a package.
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1115 (when installable
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1116 (let ((button-text (if (display-graphic-p)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1117 "Install"
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1118 "[Install]"))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1119 (button-face (if (display-graphic-p)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1120 '(:box (:line-width 2 :color "dark grey")
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1121 :background "light grey"
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1122 :foreground "black")
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1123 'link)))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1124 (insert "\n")
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1125 (insert-text-button button-text
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1126 'face button-face
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1127 'follow-link t
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1128 'package-symbol package
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1129 'action (lambda (button)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1130 (package-install
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1131 (button-get button 'package-symbol))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1132 (revert-buffer nil t)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1133 (goto-char (point-min))))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1134 (insert "\n")))))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1135
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1136
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1137 ;;;; Package menu mode.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1138
109018
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1139 (defvar package-menu-mode-map
109020
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1140 (let ((map (make-keymap))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1141 (menu-map (make-sparse-keymap "Package")))
109018
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1142 (suppress-keymap map)
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1143 (define-key map "\C-m" 'package-menu-describe-package)
109018
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1144 (define-key map "q" 'quit-window)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1145 (define-key map "n" 'next-line)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1146 (define-key map "p" 'previous-line)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1147 (define-key map "u" 'package-menu-mark-unmark)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1148 (define-key map "\177" 'package-menu-backup-unmark)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1149 (define-key map "d" 'package-menu-mark-delete)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1150 (define-key map "i" 'package-menu-mark-install)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1151 (define-key map "g" 'package-menu-revert)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1152 (define-key map "r" 'package-menu-refresh)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1153 (define-key map "~" 'package-menu-mark-obsolete-for-deletion)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1154 (define-key map "x" 'package-menu-execute)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1155 (define-key map "h" 'package-menu-quick-help)
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1156 (define-key map "?" 'package-menu-view-commentary)
109020
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1157 (define-key map [menu-bar package-menu] (cons "Package" menu-map))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1158 (define-key menu-map [mq]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1159 '(menu-item "Quit" quit-window
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1160 :help "Quit package selection"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1161 (define-key menu-map [s1] '("--"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1162 (define-key menu-map [mn]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1163 '(menu-item "Next" next-line
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1164 :help "Next Line"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1165 (define-key menu-map [mp]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1166 '(menu-item "Previous" previous-line
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1167 :help "Previous Line"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1168 (define-key menu-map [s2] '("--"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1169 (define-key menu-map [mu]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1170 '(menu-item "Unmark" package-menu-mark-unmark
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1171 :help "Clear any marks on a package and move to the next line"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1172 (define-key menu-map [munm]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1173 '(menu-item "Unmark backwards" package-menu-backup-unmark
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1174 :help "Back up one line and clear any marks on that package"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1175 (define-key menu-map [md]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1176 '(menu-item "Mark for deletion" package-menu-mark-delete
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1177 :help "Mark a package for deletion and move to the next line"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1178 (define-key menu-map [mi]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1179 '(menu-item "Mark for install" package-menu-mark-install
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1180 :help "Mark a package for installation and move to the next line"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1181 (define-key menu-map [s3] '("--"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1182 (define-key menu-map [mg]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1183 '(menu-item "Update package list" package-menu-revert
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1184 :help "Update the list of packages"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1185 (define-key menu-map [mr]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1186 '(menu-item "Refresh package list" package-menu-refresh
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1187 :help "Download the ELPA archive"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1188 (define-key menu-map [s4] '("--"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1189 (define-key menu-map [mt]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1190 '(menu-item "Mark obsolete packages" package-menu-mark-obsolete-for-deletion
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1191 :help "Mark all obsolete packages for deletion"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1192 (define-key menu-map [mx]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1193 '(menu-item "Execute actions" package-menu-execute
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1194 :help "Perform all the marked actions"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1195 (define-key menu-map [s5] '("--"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1196 (define-key menu-map [mh]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1197 '(menu-item "Help" package-menu-quick-help
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1198 :help "Show short key binding help for package-menu-mode"))
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1199 (define-key menu-map [mc]
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1200 '(menu-item "View Commentary" package-menu-view-commentary
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1201 :help "Display information about this package"))
109018
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1202 map)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1203 "Local keymap for `package-menu-mode' buffers.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1204
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1205 (defvar package-menu-sort-button-map
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1206 (let ((map (make-sparse-keymap)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1207 (define-key map [header-line mouse-1] 'package-menu-sort-by-column)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1208 (define-key map [follow-link] 'mouse-face)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1209 map)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1210 "Local keymap for package menu sort buttons.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1211
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1212 (put 'package-menu-mode 'mode-class 'special)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1213
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1214 (defun package-menu-mode ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1215 "Major mode for browsing a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1216 Letters do not insert themselves; instead, they are commands.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1217 \\<package-menu-mode-map>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1218 \\{package-menu-mode-map}"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1219 (kill-all-local-variables)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1220 (use-local-map package-menu-mode-map)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1221 (setq major-mode 'package-menu-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1222 (setq mode-name "Package Menu")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1223 (setq truncate-lines t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1224 (setq buffer-read-only t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1225 ;; Support Emacs 21.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1226 (if (fboundp 'run-mode-hooks)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1227 (run-mode-hooks 'package-menu-mode-hook)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1228 (run-hooks 'package-menu-mode-hook)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1229
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1230 (defun package-menu-refresh ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1231 "Download the ELPA archive.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1232 This fetches the file describing the current contents of
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1233 the Emacs Lisp Package Archive, and then refreshes the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1234 package menu. This lets you see what new packages are
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1235 available for download."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1236 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1237 (package-refresh-contents)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1238 (package-list-packages-internal))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1239
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1240 (defun package-menu-revert ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1241 "Update the list of packages."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1242 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1243 (package-list-packages-internal))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1244
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1245 (defun package-menu-describe-package ()
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1246 "Describe the package in the current line."
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1247 (interactive)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1248 (let ((name (package-menu-get-package)))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1249 (if name
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1250 (describe-package (intern name))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1251 (message "No package on this line"))))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1252
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1253 (defun package-menu-mark-internal (what)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1254 (unless (eobp)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1255 (let ((buffer-read-only nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1256 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1257 (delete-char 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1258 (insert what)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1259 (forward-line))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1260
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1261 ;; fixme numeric argument
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1262 (defun package-menu-mark-delete (num)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1263 "Mark a package for deletion and move to the next line."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1264 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1265 (package-menu-mark-internal "D"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1266
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1267 (defun package-menu-mark-install (num)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1268 "Mark a package for installation and move to the next line."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1269 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1270 (package-menu-mark-internal "I"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1271
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1272 (defun package-menu-mark-unmark (num)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1273 "Clear any marks on a package and move to the next line."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1274 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1275 (package-menu-mark-internal " "))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1276
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1277 (defun package-menu-backup-unmark ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1278 "Back up one line and clear any marks on that package."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1279 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1280 (forward-line -1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1281 (package-menu-mark-internal " ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1282 (forward-line -1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1283
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1284 (defun package-menu-mark-obsolete-for-deletion ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1285 "Mark all obsolete packages for deletion."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1286 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1287 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1288 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1289 (forward-line 2)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1290 (while (not (eobp))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1291 (if (looking-at ".*\\s obsolete\\s ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1292 (package-menu-mark-internal "D")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1293 (forward-line 1)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1294
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1295 (defun package-menu-quick-help ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1296 "Show short key binding help for package-menu-mode."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1297 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1298 (message "n-ext, i-nstall, d-elete, u-nmark, x-ecute, r-efresh, h-elp"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1299
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1300 (defun package-menu-view-commentary ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1301 "Display information about this package.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1302 For single-file packages, shows the commentary section from the header.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1303 For larger packages, shows the README file."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1304 (interactive)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1305 (let* ((pkg-name (package-menu-get-package))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1306 (buffer (url-retrieve-synchronously
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
1307 (concat (package-archive-url pkg-name)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1308 pkg-name
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1309 "-readme.txt")))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1310 start-point ok)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1311 (with-current-buffer buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1312 ;; FIXME: it would be nice to work with any URL type.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1313 (setq start-point url-http-end-of-headers)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1314 (setq ok (eq (url-http-parse-response) 200)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1315 (let ((new-buffer (get-buffer-create "*Package Info*")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1316 (with-current-buffer new-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1317 (let ((buffer-read-only nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1318 (erase-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1319 (insert "Package information for " pkg-name "\n\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1320 (if ok
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1321 (insert-buffer-substring buffer start-point)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1322 (insert "This package lacks a README file or commentary.\n"))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1323 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1324 (view-mode)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1325 (display-buffer new-buffer t))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1326
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1327 ;; Return the name of the package on the current line.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1328 (defun package-menu-get-package ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1329 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1330 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1331 (if (looking-at ". \\([^ \t]*\\)")
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1332 (match-string-no-properties 1))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1333
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1334 ;; Return the version of the package on the current line.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1335 (defun package-menu-get-version ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1336 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1337 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1338 (if (looking-at ". [^ \t]*[ \t]*\\([0-9.]*\\)")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1339 (match-string 1))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1340
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1341 (defun package-menu-get-status ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1342 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1343 (if (looking-at ". [^ \t]*[ \t]*[^ \t]*[ \t]*\\([^ \t]*\\)")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1344 (match-string 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1345 "")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1346
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1347 (defun package-menu-execute ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1348 "Perform all the marked actions.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1349 Packages marked for installation will be downloaded and
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1350 installed. Packages marked for deletion will be removed.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1351 Note that after installing packages you will want to restart
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1352 Emacs."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1353 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1354 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1355 (while (not (eobp))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1356 (let ((cmd (char-after))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1357 (pkg-name (package-menu-get-package))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1358 (pkg-vers (package-menu-get-version))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1359 (pkg-status (package-menu-get-status)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1360 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1361 ((eq cmd ?D)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1362 (when (and (string= pkg-status "installed")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1363 (string= pkg-name "package"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1364 ;; FIXME: actually, we could be tricky and remove all info.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1365 ;; But that is drastic and the user can do that instead.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1366 (error "Can't delete most recent version of `package'"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1367 ;; Ask for confirmation here? Maybe if package status is ""?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1368 ;; Or if any lisp from package is actually loaded?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1369 (message "Deleting %s-%s..." pkg-name pkg-vers)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1370 (package-delete pkg-name pkg-vers)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1371 (message "Deleting %s-%s... done" pkg-name pkg-vers))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1372 ((eq cmd ?I)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1373 (package-install (intern pkg-name)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1374 (forward-line))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1375 (package-menu-revert))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1376
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1377 (defun package-print-package (package version key desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1378 (let ((face
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1379 (cond ((string= key "built-in") 'font-lock-builtin-face)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1380 ((string= key "available") 'default)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1381 ((string= key "held") 'font-lock-constant-face)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1382 ((string= key "disabled") 'font-lock-warning-face)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1383 ((string= key "installed") 'font-lock-comment-face)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1384 (t ; obsolete, but also the default.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1385 'font-lock-warning-face))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1386 (insert (propertize " " 'font-lock-face face))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1387 (insert-text-button (symbol-name package)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1388 'face 'link
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1389 'follow-link t
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1390 'package-symbol package
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1391 'action (lambda (button)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1392 (describe-package
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1393 (button-get button 'package-symbol))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1394 (indent-to 20 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1395 (insert (propertize (package-version-join version) 'font-lock-face face))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1396 (indent-to 32 1)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1397 (insert (propertize key 'font-lock-face face))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1398 ;; FIXME: this 'when' is bogus...
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1399 (when desc
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1400 (indent-to 43 1)
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1401 (let ((opoint (point)))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1402 (insert (propertize desc 'font-lock-face face))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1403 (upcase-region opoint (min (point) (1+ opoint)))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1404 (insert "\n")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1405
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1406 (defun package-list-maybe-add (package version status description result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1407 (unless (assoc (cons package version) result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1408 (setq result (cons (list (cons package version) status description)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1409 result)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1410 result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1411
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1412 ;; This decides how we should sort; nil means by package name.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1413 (defvar package-menu-sort-key nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1414
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1415 (defun package-list-packages-internal ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1416 (package-initialize) ; FIXME: do this here?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1417 (with-current-buffer (get-buffer-create "*Packages*")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1418 (setq buffer-read-only nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1419 (erase-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1420 (let ((info-list)
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1421 name desc hold
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1422 builtin)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1423 ;; List installed packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1424 (dolist (elt package-alist)
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1425 ;; Ignore the Emacs package.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1426 (setq name (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1427 desc (cdr elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1428 hold (assq name package-load-list))
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1429 (unless (eq name 'emacs)
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1430 (setq info-list
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1431 (package-list-maybe-add
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1432 name (package-desc-vers desc)
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1433 ;; FIXME: it turns out to be tricky to see if this
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1434 ;; package is presently activated.
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1435 (cond ((stringp (cadr hold))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1436 "held")
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1437 ((and (setq builtin (assq name package--builtins))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
1438 (version-list-=
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1439 (package-desc-vers (cdr builtin))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
1440 (package-desc-vers desc)))
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1441 "built-in")
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1442 (t "installed"))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1443 (package-desc-doc desc)
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1444 info-list))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1445 ;; List available packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1446 (dolist (elt package-archive-contents)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1447 (setq name (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1448 desc (cdr elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1449 hold (assq name package-load-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1450 (unless (and hold (stringp (cadr hold))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1451 (package-installed-p
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
1452 name (version-to-list (cadr hold))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1453 (setq info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1454 (package-list-maybe-add name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1455 (package-desc-vers desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1456 (if (and hold (null (cadr hold)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1457 "disabled"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1458 "available")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1459 (package-desc-doc (cdr elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1460 info-list))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1461 ;; List obsolete packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1462 (mapc (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1463 (mapc (lambda (inner-elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1464 (setq info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1465 (package-list-maybe-add (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1466 (package-desc-vers
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1467 (cdr inner-elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1468 "obsolete"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1469 (package-desc-doc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1470 (cdr inner-elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1471 info-list)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1472 (cdr elt)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1473 package-obsolete-alist)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1474 (let ((selector (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1475 ((string= package-menu-sort-key "Version")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1476 ;; FIXME this doesn't work.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1477 #'(lambda (e) (cdr (car e))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1478 ((string= package-menu-sort-key "Status")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1479 #'(lambda (e) (car (cdr e))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1480 ((string= package-menu-sort-key "Description")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1481 #'(lambda (e) (car (cdr (cdr e)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1482 (t ; "Package" is default.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1483 #'(lambda (e) (symbol-name (car (car e))))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1484 (setq info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1485 (sort info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1486 (lambda (left right)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1487 (let ((vleft (funcall selector left))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1488 (vright (funcall selector right)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1489 (string< vleft vright))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1490 (mapc (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1491 (package-print-package (car (car elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1492 (cdr (car elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1493 (car (cdr elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1494 (car (cdr (cdr elt)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1495 info-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1496 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1497 (current-buffer)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1498
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1499 (defun package-menu-sort-by-column (&optional e)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1500 "Sort the package menu by the last column clicked on."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1501 (interactive (list last-input-event))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1502 (if e (mouse-select-window e))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1503 (let* ((pos (event-start e))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1504 (obj (posn-object pos))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1505 (col (if obj
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1506 (get-text-property (cdr obj) 'column-name (car obj))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1507 (get-text-property (posn-point pos) 'column-name))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1508 (setq package-menu-sort-key col))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1509 (package-list-packages-internal))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1510
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1511 (defun package--list-packages ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1512 "Display a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1513 Helper function that does all the work for the user-facing functions."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1514 (with-current-buffer (package-list-packages-internal)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1515 (package-menu-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1516 ;; Set up the header line.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1517 (setq header-line-format
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1518 (mapconcat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1519 (lambda (pair)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1520 (let ((column (car pair))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1521 (name (cdr pair)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1522 (concat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1523 ;; Insert a space that aligns the button properly.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1524 (propertize " " 'display (list 'space :align-to column)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1525 'face 'fixed-pitch)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1526 ;; Set up the column button.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1527 (if (string= name "Version")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1528 name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1529 (propertize name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1530 'column-name name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1531 'help-echo "mouse-1: sort by column"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1532 'mouse-face 'highlight
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1533 'keymap package-menu-sort-button-map)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1534 ;; We take a trick from buff-menu and have a dummy leading
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1535 ;; space to align the header line with the beginning of the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1536 ;; text. This doesn't really work properly on Emacs 21,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1537 ;; but it is close enough.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1538 '((0 . "")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1539 (2 . "Package")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1540 (20 . "Version")
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1541 (32 . "Status")
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1542 (43 . "Description"))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1543 ""))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1544
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1545 ;; It's okay to use pop-to-buffer here. The package menu buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1546 ;; has keybindings, and the user just typed 'M-x
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1547 ;; package-list-packages', suggesting that they might want to use
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1548 ;; them.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1549 (pop-to-buffer (current-buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1550
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1551 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1552 (defun package-list-packages ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1553 "Display a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1554 Fetches the updated list of packages before displaying.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1555 The list is displayed in a buffer named `*Packages*'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1556 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1557 (package-refresh-contents)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1558 (package--list-packages))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1559
109970
77c4a65b9011 * emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
1560 ;;;###autoload
77c4a65b9011 * emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
1561 (defalias 'list-packages 'package-list-packages)
77c4a65b9011 * emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
1562
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1563 (defun package-list-packages-no-fetch ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1564 "Display a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1565 Does not fetch the updated list of packages before displaying.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1566 The list is displayed in a buffer named `*Packages*'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1567 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1568 (package--list-packages))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1569
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1570 (provide 'package)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1571
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1572 ;;; package.el ends here