annotate lisp/emacs-lisp/package.el @ 110028:2547676f6961

smiley-regexp-alist: Don't delete the semicolon before the blinking smiley by Miles Bader <miles@gnu.org>; Disallow ;;) from being treated as a blink smiley by Simon Josefsson <simon@josefsson.org>. 2009-03-24 Miles Bader <miles@gnu.org> * smiley.el (smiley-regexp-alist): Don't delete the semicolon before the blinking smiley. 2009-03-24 Simon Josefsson <simon@josefsson.org> * smiley.el (smiley-regexp-alist): Disallow ;;) from being treated as a blink smiley.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 30 Aug 2010 06:28:53 +0000
parents 10e66ac64b61
children 8be2f62f7851
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))
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
219 (defvar url-http-end-of-headers)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
221 (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
222 "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
223 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
224 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
225 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
226 :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
227 :value-type (string :tag "Archive URL"))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
228 :risky t
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
229 :group 'package
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
230 :version "24.1")
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (defconst package-archive-version 1
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 "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
234 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
235
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (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
237 "Version of package.el.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; 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
240 (defvar package-archive-contents nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 "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
242 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
243 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
244 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
245 '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
246 the archive from which it came.")
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
247 (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
248
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (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
250 "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
251 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
252 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
253 packages in `package-directory-list'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 :type 'directory
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
255 :risky t
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (defcustom package-directory-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 ;; 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
261 (let (result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (dolist (f load-path)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (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
264 (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
265 (nreverse result))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 "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
267 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
268
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 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
270 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
271 :type '(repeat directory)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
272 :risky t
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 :group 'package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 :version "24.1")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
276 ;; The value is precomputed in finder-inf.el, but don't load that
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
277 ;; until it's needed (i.e. when `package-intialize' is called).
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
278 (defvar package--builtins nil
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
279 "Alist of built-in packages.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
280 Each element has the form (PKG . DESC), where PKG is a package
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
281 name (a symbol) and DESC is a vector that describes the package.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
283 The vector DESC has the form [VERSION REQS DOCSTRING].
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
284 VERSION is a version list.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
285 REQS is a list of packages (symbols) required by the package.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
286 DOCSTRING is a brief description of the package.")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
287 (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
288
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
289 (defvar package-alist nil
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 "Alist of all packages available for activation.
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
291 Each element has the form (PKG . DESC), where PKG is a package
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
292 name (a symbol) and DESC is a vector that describes the package.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
294 The vector DESC has the form [VERSION REQS DOCSTRING].
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
295 VERSION is a version list.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
296 REQS is a list of packages (symbols) required by the package.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
297 DOCSTRING is a brief description of the package.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
298
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
299 This variable is set automatically by `package-load-descriptor',
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
300 called via `package-initialize'. To change which packages are
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
301 loaded and/or activated, customize `package-load-list'.")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
302 (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
303
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
304 (defvar package-activated-list nil
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 "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
306 (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
307
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (defvar package-obsolete-alist nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 "Representation of obsolete packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 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
311 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
312 (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
313
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (defconst package-subdirectory-regexp
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 "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
317 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
318 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
319
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (defun package-version-join (l)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 "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
322 (mapconcat 'int-to-string l "."))
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 (defun package-strip-version (dirname)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 "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
326 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
327 (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
328 (match-string 1 dirname)))
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-load-descriptor (dir package)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
331 "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
332 (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
333 (pkg-file (expand-file-name
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
334 (concat (package-strip-version package) "-pkg")
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
335 pkg-dir)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
336 (when (and (file-directory-p pkg-dir)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
337 (file-exists-p (concat pkg-file ".el")))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
338 (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
339
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (defun package-load-all-descriptors ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 "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
342 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
343 `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
344 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
345
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 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
347 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
348 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
349 (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
350 name version force)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (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
352 (when (file-directory-p dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (dolist (subdir (directory-files dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (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
355 (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
356 (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
357 version (match-string 2 subdir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 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
359 (when (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ((null force)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 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
362 ((null (setq force (cadr force)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 nil) ; disabled
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 ((eq force t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ((stringp force) ; held
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
367 (version-list-= (version-to-list version)
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
368 (version-to-list force)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (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
371 (package-load-descriptor dir subdir))))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (defsubst package-desc-vers (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 "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
375 (aref desc 0))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (defsubst package-desc-reqs (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 "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
379 (aref desc 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (defsubst package-desc-doc (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 "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
383 (aref desc 2))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (defsubst package-desc-kind (desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 "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
387 (aref desc 3))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
389 (defun package--dir (name version-string)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
390 (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
391 (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
392 pkg-dir)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (while dir-list
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
394 (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
395 (if (file-directory-p subdir-full)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
396 (setq pkg-dir subdir-full
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
397 dir-list nil)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (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
399 pkg-dir))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
400
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
401 (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
402 (let* ((name (symbol-name package))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
403 (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
404 (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
405 (unless pkg-dir
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (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
407 name version-str))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
408 ;; Add info node.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (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
410 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 ;; 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
412 (require 'info)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (info-initialize)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (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
415 ;; 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
416 (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
417 (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
418 (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
419 ;; Don't return nil.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 t))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (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
423 "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
424 (let ((elt (assq package package--builtins)))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
425 (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
426
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ;; FIXME: return a reason instead?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (defun package-activate (package version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 "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
430 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
431 ;; 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
432 ;; 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
433 ;; 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
434 ;; 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
435 ;; 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
436 ;; no sense.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (unless (eq package 'emacs)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (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
439 (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
440 (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
441 ;; 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
442 (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
443 (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
444 (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
445 (let* ((req (car req-list))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (req-name (car req))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (req-version (cadr req)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (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
449 (setq keep-going nil)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (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
451 (if keep-going
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (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
453 ;; 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
454 ;; 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
455 ;; 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
456 (and (memq package package-activated-list)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
457 (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
458
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (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
460 "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
461 (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
462 (if elt
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 ;; 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
464 ;; it the list.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (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
466 (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
467 (cdr elt))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 ;; Make a new association.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (setq package-obsolete-alist
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (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
471 pkg-vec)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 package-obsolete-alist)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 ;; (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
475 ;; (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
476 (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
477 &optional docstring requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 "Define a new package.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 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
480 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
481 of integers.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 DOCSTRING is the optional description.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 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
484 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
485 (let* ((name (intern name-str))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (pkg-desc (assq name package-alist))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
487 (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
488 (new-pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (cons name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (vector new-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
494 (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
495 requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 docstring))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 ;; 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
498 (if (or (not pkg-desc)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
499 (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
500 new-version))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (when pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 ;; 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
504 (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
505 (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
506 ;; Add package to the alist.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (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
508 ;; 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
509 ;; 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
510 ;; 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
511 (unless (version-list-= new-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
512 (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
513 ;; The package is born obsolete.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 (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
515
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 ;; From Emacs 22.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 (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
518 "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
519 (unless (file-exists-p file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 (write-region
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (concat ";;; " (file-name-nondirectory file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 " --- automatically extracted autoloads\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ";;\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 ";;; Code:\n\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 " \n;; Local Variables:\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 ";; version-control: never\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 ";; no-byte-compile: t\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 ";; no-update-autoloads: t\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 ";; End:\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 ";;; " (file-name-nondirectory file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 " ends here\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 nil file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 (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
536 (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
537 (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
538 (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
539 (version-control 'never))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 (require 'autoload)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 (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
542 (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
543 (update-directory-autoloads pkg-dir)))
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-untar-buffer ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 "Untar the current buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 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
548 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
549 `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
550 (require 'tar-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (if (fboundp 'tar-untar-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 ;; 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
554 ;; whole buffer to play with.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 (delete-region (point-min) (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 (tar-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 (tar-untar-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 ;; FIXME: check the result.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (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
560 "xf" "-")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 (defun package-unpack (name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 (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
564 package-user-dir)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 ;; Be careful!!
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (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
567 (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
568 (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
569 ; more confident
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 (directory-files pkg-dir t "^[^.]")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 (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
572 (package-untar-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 (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
574 (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
575 (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
576
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
577 (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
578 (let ((buffer-file-coding-system 'no-conversion))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
579 (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
580
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (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
582 "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
583 ;; Special case "package".
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 (if (string= file-name "package")
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
585 (package--write-file-no-coding
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
586 (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
587 nil)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 (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
589 package-user-dir))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 (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
591 (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
592 (make-directory pkg-dir t)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
593 (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
594 (let ((print-level nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 (print-length nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 (write-region
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 (concat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 (prin1-to-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 (list 'define-package
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 file-name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 (list 'quote
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 ;; 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
605 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 (list (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (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
609 requires))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 "\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 pkg-file
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 nil nil nil 'excl))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 (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
615 (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
616 (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
617
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (defun package-handle-response ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 "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
620 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
621 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
622 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
623 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
624 ;; We assume HTTP here.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (require 'url-http)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 (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
627 (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
628 (display-buffer (current-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 (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
630 (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
631 (end-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 (point)))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 (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
635 "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
636 (let ((buffer (url-retrieve-synchronously
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
637 (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
638 (symbol-name name) "-" version ".el"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 (with-current-buffer buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (delete-region (point-min) (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (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
645 (kill-buffer buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 (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
648 "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
649 (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
650 (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
651 (symbol-name name) "-" version ".tar"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 (with-current-buffer tar-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (package-unpack name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (kill-buffer tar-buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
659 (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
660 (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
661 (and pkg-desc
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
662 (version-list-<= min-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
663 (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
664
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
665 (defun package-compute-transaction (package-list requirements)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
666 "Return a list of packages to be installed, including PACKAGE-LIST.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
667 PACKAGE-LIST should be a list of package names (symbols).
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
668
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
669 REQUIREMENTS should be a list of additional requirements; each
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
670 element in this list should have the form (PACKAGE VERSION),
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
671 where PACKAGE is a package name and VERSION is the required
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
672 version of that package (as a list).
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
673
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
674 This function recursively computes the requirements of the
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
675 packages in REQUIREMENTS, and returns a list of all the packages
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
676 that must be installed. Packages that are already installed are
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
677 not included in this list."
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 (dolist (elt requirements)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (let* ((next-pkg (car elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 (next-version (cadr elt)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 (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
682 ;; 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
683 ;; blocked via `package-load-list'.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 (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
685 hold)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (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
687 (setq hold (cadr hold))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 (cond ((eq hold nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 (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
690 (symbol-name next-pkg)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 ((null (stringp hold))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (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
693 ((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
694 (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
695 but version %s required"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (symbol-name next-pkg) hold
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 (package-version-join next-version)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (unless pkg-desc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 (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
700 (symbol-name next-pkg)))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
701 (unless (version-list-<= next-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
702 (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
703 (error
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 "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
705 (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
706 (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
707 ;; Only add to the transaction if we don't already have it.
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
708 (unless (memq next-pkg package-list)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
709 (setq package-list (cons next-pkg package-list)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
710 (setq package-list
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
711 (package-compute-transaction package-list
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 (package-desc-reqs
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 (cdr pkg-desc))))))))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
714 package-list)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (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
717 "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
718 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
719 (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
720 (more-left
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 (condition-case nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 ;; 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
723 (progn (ignore (read-from-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (substring str (cdr read-data))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (end-of-file nil))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (if more-left
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 (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
729 (car read-data))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 (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
732 "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
733 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
734 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
735 (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
736 (if (file-exists-p filename)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (with-temp-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (insert-file-contents-literally filename)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (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
740 (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
741 (point-max)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 (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
743 (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
744 (car contents) package-archive-version))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 (cdr contents))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
747 (defun package-read-all-archive-contents ()
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
748 "Re-read `archive-contents', if it exists.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
749 If successful, set `package-archive-contents'."
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
750 (dolist (archive package-archives)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
751 (package-read-archive-contents (car archive))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
753 (defun package-read-archive-contents (archive)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
754 "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
755 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
756 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
757 (let ((archive-contents (package--read-archive-file
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
758 (concat "archives/" archive
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
759 "/archive-contents"))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
760 (if archive-contents
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
761 ;; 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
762 ;; internal representation.
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
763 ;; TODO: merge archive lists
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
764 (dolist (package archive-contents)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
765 (package--add-to-archive-contents package archive)))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
766
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
767 (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
768 "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
769 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
770 (let* ((name (car package))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
771 (version (aref (cdr package) 0))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
772 (entry (cons (car package)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
773 (vconcat (cdr package) (vector archive))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
774 (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
775 (when (or (not existing-package)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
776 (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
777 (add-to-list 'package-archive-contents entry))))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
778
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
779 (defun package-download-transaction (package-list)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
780 "Download and install all the packages in PACKAGE-LIST.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
781 PACKAGE-LIST should be a list of package names (symbols).
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
782 This function assumes that all package requirements in
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
783 PACKAGE-LIST are satisfied, i.e. that PACKAGE-LIST is computed
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
784 using `package-compute-transaction'."
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
785 (dolist (elt package-list)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 (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
787 ;; 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
788 ;; `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
789 (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
790 (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
791 (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
792 (kind (package-desc-kind desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 ((eq kind 'tar)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 (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
796 ((eq kind 'single)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 (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
798 (package-desc-doc desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 (package-desc-reqs desc)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 (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
802
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (defun package-install (name)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 "Install the package named NAME.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 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
807 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
808 (interactive
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
809 (list (intern (completing-read "Install package: "
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
810 (mapcar (lambda (elt)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
811 (cons (symbol-name (car elt))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
812 nil))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
813 package-archive-contents)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
814 nil t))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (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
816 (unless pkg-desc
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
817 (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
818 (symbol-name name)))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
819 (package-download-transaction
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
820 (package-compute-transaction (list name)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
821 (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
822 ;; Try to activate it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
823 (package-initialize))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
825 (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
826 "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
827 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
828 Otherwise return nil."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 (if v-str
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
830 (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
831 (match-string 1 v-str)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 (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
833 v-str))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
834
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 (defun package-buffer-info ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 "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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 (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
848 (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
849 (desc (match-string 2))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 (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
851 (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
852 (progn
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 ;; 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
854 (forward-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855 (narrow-to-region start (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856 (require 'lisp-mnt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 ;; 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
858 (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
859 (requires (if requires-str
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 (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
861 ;; 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
862 ;; 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
863 ;; 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
864 (pkg-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 (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
866 (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
867 (commentary (lm-commentary)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
868 (unless pkg-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 (error
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 "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
871 ;; 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
872 (setq requires
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
876 (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
877 requires))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 (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
879 (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
880 (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
881 (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
882 (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
883 (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
884
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 (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
886 "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
887 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
888 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
889 (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
890 (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
891 (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
892 (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
893 ;; Extract the package descriptor.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 (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
895 ;; Requires GNU tar.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 (concat "tar -xOf " file " "
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 pkg-name "-" pkg-version "/"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 pkg-name "-pkg.el")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 (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
900 (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
901 (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
902 (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
903 (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
904 (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
905 (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
906
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 (readme (shell-command-to-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 ;; Requires GNU tar.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 (concat "tar -xOf " file " "
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910 pkg-name "-" pkg-version "/README"))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 (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
912 (error "Inconsistent versions!"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 (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
914 (error "Inconsistent names!"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915 ;; Kind of a hack.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 (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
917 (setq readme nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 ;; 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
919 (if (eq (car requires) 'quote)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 (setq requires (car (cdr requires))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 (setq requires
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 (mapcar
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 (list (car elt)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
925 (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
926 requires))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 (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
928
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
929 (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
930 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
931 (save-restriction
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932 (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
933 (requires (aref pkg-info 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934 (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
935 "No description available."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936 (aref pkg-info 2)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (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
938 ;; Download and install the dependencies.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 (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
940 (package-download-transaction transaction))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 ;; Install the package itself.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943 ((eq type 'single)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
944 (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
945 ((eq type 'tar)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 (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
947 (t
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
948 (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
949 ;; Try to activate it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
950 (package-initialize)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
951
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 (defun package-install-from-buffer ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 "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
955 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
956 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
957 info node `(elisp)Library Headers'."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (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
960
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 (defun package-install-file (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 "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
964 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
965 (interactive "fPackage file name: ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966 (with-temp-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 (insert-file-contents-literally file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969 ((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
970 ((string-match "\\.tar$" file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
971 (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
972 (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
973
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 (defun package-delete (name version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 (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
976 (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
977 package-user-dir)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978 ;; FIXME: query user?
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
979 'always))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
980
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109567
diff changeset
981 (defun package-archive-url (name)
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
982 "Return the archive containing the package NAME."
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
983 (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
984 (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
985
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
986 (defun package--download-one-archive (archive file)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
987 "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
988 (let* ((archive-name (car archive))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
989 (archive-url (cdr archive))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
990 (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
991 (dir (expand-file-name archive-name dir))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
992 (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
993 (with-current-buffer buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
994 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
995 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
996 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
997 (delete-region (point-min) (point))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
998 (make-directory dir t)
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
999 (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
1000 (let ((version-control 'never))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1001 (save-buffer)))
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1002 (kill-buffer buffer)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1003
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1004 (defun package-refresh-contents ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1005 "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
1006 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
1007 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
1008 download."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010 (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
1011 (make-directory package-user-dir t))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1012 (dolist (archive package-archives)
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1013 (condition-case nil
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1014 (package--download-one-archive archive "archive-contents")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1015 (error (message "Failed to download archive `%s'."
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1016 (car archive)))))
109567
0fc9f7a0d319 Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents: 109027
diff changeset
1017 (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
1018
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1019 ;;;###autoload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1020 (defun package-initialize ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1021 "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
1022 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
1023 (interactive)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1024 (require 'finder-inf nil t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1025 (setq package-alist package--builtins)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1026 (setq package-activated-list (mapcar #'car package-alist))
109016
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))
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1055 (list (if (equal val "") guess (intern val)))))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1056 (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
1057 (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
1058 (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
1059 (called-interactively-p 'interactive))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1060 (with-help-window (help-buffer)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1061 (with-current-buffer standard-output
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1062 (describe-package-1 package)))))
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1063
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1064 (defun describe-package-1 (package)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1065 (require 'lisp-mnt)
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1066 (let ((package-name (symbol-name package))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1067 (built-in (assq package package--builtins))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1068 desc pkg-dir 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 ")
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1071 (if (setq desc (cdr (assq package package-alist)))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1072 ;; This package is loaded (i.e. in `package-alist').
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1073 (progn
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1074 (setq version (package-version-join (package-desc-vers desc)))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1075 (cond (built-in
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1076 (princ "a built-in package.\n\n"))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1077 ((setq pkg-dir (package--dir package-name version))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1078 (insert "an installed package.\n\n"))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1079 (t ;; This normally does not happen.
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1080 (insert "a deleted package.\n\n")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1081 (setq version nil))))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1082 ;; This package is not installed.
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1083 (setq desc (cdr (assq package package-archive-contents))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1084 version (package-version-join (package-desc-vers desc))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1085 installable t)
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1086 (insert "an uninstalled package.\n\n"))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1087
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1088 (insert " " (propertize "Status" 'font-lock-face 'bold) ": ")
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1089 (cond (pkg-dir
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1090 (insert (propertize "Installed"
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1091 'font-lock-face 'font-lock-comment-face))
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1092 (insert " in `")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1093 ;; Todo: Add button for uninstalling.
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1094 (help-insert-xref-button (file-name-as-directory pkg-dir)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1095 'help-package-def pkg-dir)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1096 (insert "'."))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1097 (installable
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1098 (insert "Available -- ")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1099 (let ((button-text (if (display-graphic-p)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1100 "Install"
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1101 "[Install]"))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1102 (button-face (if (display-graphic-p)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1103 '(:box (:line-width 2 :color "dark grey")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1104 :background "light grey"
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1105 :foreground "black")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1106 'link)))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1107 (insert-text-button button-text
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1108 'face button-face
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1109 'follow-link t
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1110 'package-symbol package
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1111 'action 'package-install-button-action)))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1112 (built-in
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1113 (insert (propertize "Built-in"
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1114 'font-lock-face 'font-lock-builtin-face) "."))
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1115 (t (insert "Deleted.")))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1116 (insert "\n")
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1117 (and version
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1118 (> (length version) 0)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1119 (insert " "
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1120 (propertize "Version" 'font-lock-face 'bold) ": " version "\n"))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1121 (setq reqs (package-desc-reqs desc))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1122 (when reqs
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1123 (insert " " (propertize "Requires" 'font-lock-face 'bold) ": ")
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1124 (let ((first t)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1125 name vers text)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1126 (dolist (req reqs)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1127 (setq name (car req)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1128 vers (cadr req)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1129 text (format "%s-%s" (symbol-name name)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1130 (package-version-join vers)))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1131 (cond (first (setq first nil))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1132 ((>= (+ 2 (current-column) (length text))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1133 (window-width))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1134 (insert ",\n "))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1135 (t (insert ", ")))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1136 (help-insert-xref-button text 'help-package name))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1137 (insert "\n")))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1138 (insert " " (propertize "Summary" 'font-lock-face 'bold)
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1139 ": " (package-desc-doc desc) "\n\n")
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1140
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1141 (if (assq package package--builtins)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1142 ;; For built-in packages, insert the commentary.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1143 (let ((fn (locate-file (concat package-name ".el") load-path
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1144 load-file-rep-suffixes))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1145 (opoint (point)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1146 (insert (or (lm-commentary fn) ""))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1147 (save-excursion
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1148 (goto-char opoint)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1149 (when (re-search-forward "^;;; Commentary:\n" nil t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1150 (replace-match ""))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1151 (while (re-search-forward "^\\(;+ ?\\)" nil t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1152 (replace-match ""))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1153 (let ((readme (expand-file-name (concat package-name "-readme.txt")
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1154 package-user-dir)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1155 ;; For elpa packages, try downloading the commentary. If that
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1156 ;; fails, try an existing readme file in `package-user-dir'.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1157 (cond ((let ((buffer (ignore-errors
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1158 (url-retrieve-synchronously
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1159 (concat (package-archive-url package)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1160 package-name "-readme.txt"))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1161 response)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1162 (when buffer
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1163 (with-current-buffer buffer
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1164 (setq response (url-http-parse-response))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1165 (if (or (< response 200) (>= response 300))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1166 (setq response nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1167 (setq buffer-file-name
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1168 (expand-file-name readme package-user-dir))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1169 (delete-region (point-min) (1+ url-http-end-of-headers))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1170 (save-buffer)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1171 (when response
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1172 (insert-buffer-substring buffer)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1173 (kill-buffer buffer)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1174 t))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1175 ((file-readable-p readme)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1176 (insert-file-contents readme)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1177 (goto-char (point-max))))))))
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1178
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1179 (defun package-install-button-action (button)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1180 (let ((package (button-get button 'package-symbol)))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1181 (when (y-or-n-p (format "Install package `%s'? " package))
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1182 (package-install package)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1183 (revert-buffer nil t)
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1184 (goto-char (point-min)))))
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1185
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109020
diff changeset
1186
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1187 ;;;; Package menu mode.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1188
109018
3fa4756bb7be emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 109016
diff changeset
1189 (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
1190 (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
1191 (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
1192 (suppress-keymap map)
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1193 (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
1194 (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
1195 (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
1196 (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
1197 (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
1198 (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
1199 (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
1200 (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
1201 (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
1202 (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
1203 (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
1204 (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
1205 (define-key map "h" 'package-menu-quick-help)
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1206 (define-key map "?" 'package-menu-describe-package)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1207 (define-key map [follow-link] 'mouse-face)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1208 (define-key map [mouse-2] 'mouse-select-window)
109020
9087d6113b47 * lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109018
diff changeset
1209 (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
1210 (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
1211 '(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
1212 :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
1213 (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
1214 (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
1215 '(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
1216 :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
1217 (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
1218 '(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
1219 :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
1220 (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
1221 (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
1222 '(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
1223 :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
1224 (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
1225 '(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
1226 :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
1227 (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
1228 '(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
1229 :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
1230 (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
1231 '(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
1232 :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
1233 (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
1234 (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
1235 '(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
1236 :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
1237 (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
1238 '(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
1239 :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
1240 (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
1241 (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
1242 '(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
1243 :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
1244 (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
1245 '(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
1246 :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
1247 (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
1248 (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
1249 '(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
1250 :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
1251 (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
1252 '(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
1253 :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
1254 map)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1255 "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
1256
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1257 (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
1258 (let ((map (make-sparse-keymap)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1259 (define-key map [header-line mouse-1] 'package-menu-sort-by-column)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1260 (define-key map [header-line mouse-2] 'package-menu-sort-by-column)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1261 (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
1262 map)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1263 "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
1264
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1265 (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
1266
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1267 (defun package-menu-mode ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1268 "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
1269 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
1270 \\<package-menu-mode-map>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1271 \\{package-menu-mode-map}"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1272 (kill-all-local-variables)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1273 (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
1274 (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
1275 (setq mode-name "Package Menu")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1276 (setq truncate-lines t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1277 (setq buffer-read-only t)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1278 ;; Support Emacs 21.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1279 (if (fboundp 'run-mode-hooks)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1280 (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
1281 (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
1282
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1283 (defun package-menu-refresh ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1284 "Download the ELPA archive.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1285 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
1286 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
1287 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
1288 available for download."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1289 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1290 (package-refresh-contents)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1291 (package--generate-package-list))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1292
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1293 (defun package-menu-revert ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1294 "Update the list of packages."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1295 (interactive)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1296 (package--generate-package-list))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1297
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1298 (defun package-menu-describe-package ()
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1299 "Describe the package in the current line."
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1300 (interactive)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1301 (let ((name (package-menu-get-package)))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1302 (if name
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1303 (describe-package (intern name))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1304 (message "No package on this line"))))
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1305
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1306 (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
1307 (unless (eobp)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1308 (let ((buffer-read-only nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1309 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1310 (delete-char 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1311 (insert what)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1312 (forward-line))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1313
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1314 ;; fixme numeric argument
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1315 (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
1316 "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
1317 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1318 (package-menu-mark-internal "D"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1319
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1320 (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
1321 "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
1322 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1323 (package-menu-mark-internal "I"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1324
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1325 (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
1326 "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
1327 (interactive "p")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1328 (package-menu-mark-internal " "))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1329
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1330 (defun package-menu-backup-unmark ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1331 "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
1332 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1333 (forward-line -1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1334 (package-menu-mark-internal " ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1335 (forward-line -1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1336
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1337 (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
1338 "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
1339 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1340 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1341 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1342 (forward-line 2)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1343 (while (not (eobp))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1344 (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
1345 (package-menu-mark-internal "D")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1346 (forward-line 1)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1347
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1348 (defun package-menu-quick-help ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1349 "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
1350 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1351 (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
1352
109992
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1353 (define-obsolete-function-alias
640cdeb464c1 Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents: 109970
diff changeset
1354 'package-menu-view-commentary 'package-menu-describe-package "24.1")
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1355
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1356 ;; 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
1357 (defun package-menu-get-package ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1358 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1359 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1360 (if (looking-at ". \\([^ \t]*\\)")
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1361 (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
1362
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1363 ;; 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
1364 (defun package-menu-get-version ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1365 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1366 (beginning-of-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1367 (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
1368 (match-string 1))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1369
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1370 (defun package-menu-get-status ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1371 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1372 (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
1373 (match-string 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1374 "")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1375
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1376 (defun package-menu-execute ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1377 "Perform all the marked actions.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1378 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
1379 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
1380 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
1381 Emacs."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1382 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1383 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1384 (while (not (eobp))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1385 (let ((cmd (char-after))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1386 (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
1387 (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
1388 (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
1389 (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1390 ((eq cmd ?D)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1391 (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
1392 (string= pkg-name "package"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1393 ;; 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
1394 ;; 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
1395 (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
1396 ;; 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
1397 ;; 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
1398 (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
1399 (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
1400 (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
1401 ((eq cmd ?I)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1402 (package-install (intern pkg-name)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1403 (forward-line))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1404 (package-menu-revert))
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-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
1407 (let ((face
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1408 (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
1409 ((string= key "available") 'default)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1410 ((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
1411 ((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
1412 ((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
1413 (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
1414 'font-lock-warning-face))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1415 (insert (propertize " " 'font-lock-face face))
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1416 (insert-text-button (symbol-name package)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1417 'face 'link
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1418 'follow-link t
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1419 'package-symbol package
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1420 'action (lambda (button)
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1421 (describe-package
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1422 (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
1423 (indent-to 20 1)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1424 (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
1425 (indent-to 32 1)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1426 (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
1427 ;; FIXME: this 'when' is bogus...
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1428 (when desc
109027
858e3e43cfd5 Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
1429 (indent-to 43 1)
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1430 (let ((opoint (point)))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1431 (insert (propertize desc 'font-lock-face face))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1432 (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
1433 (insert "\n")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1434
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1435 (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
1436 (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
1437 (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
1438 result)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1439 result)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1440
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1441 ;; 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
1442 (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
1443
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1444 (defun package--generate-package-list (&optional packages)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1445 (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
1446 (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
1447 (setq buffer-read-only nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1448 (erase-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1449 (let ((info-list)
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1450 name desc hold
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1451 builtin)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1452 ;; List installed packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1453 (dolist (elt package-alist)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1454 (setq name (car elt))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1455 (when (and (not (eq name 'emacs)) ; Hide the `emacs' package.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1456 (or (null packages)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1457 (memq name packages)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1458 (setq desc (cdr elt)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1459 hold (cadr (assq name package-load-list))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1460 builtin (cdr (assq name package--builtins)))
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1461 (setq info-list
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1462 (package-list-maybe-add
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1463 name (package-desc-vers desc)
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1464 ;; FIXME: it turns out to be tricky to see if this
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1465 ;; package is presently activated.
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1466 (cond ((stringp hold) "held")
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1467 ((and builtin
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
1468 (version-list-=
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1469 (package-desc-vers builtin)
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109602
diff changeset
1470 (package-desc-vers desc)))
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1471 "built-in")
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1472 (t "installed"))
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1473 (package-desc-doc desc)
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1474 info-list))))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1475
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1476 ;; List available and disabled packages
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1477 (dolist (elt package-archive-contents)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1478 (setq name (car elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1479 desc (cdr elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1480 hold (assq name package-load-list))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1481 (when (or (null packages)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1482 (memq name packages))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1483 (setq info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1484 (package-list-maybe-add name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1485 (package-desc-vers desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1486 (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
1487 "disabled"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1488 "available")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1489 (package-desc-doc (cdr elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1490 info-list))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1491 ;; List obsolete packages
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1492 (mapc (lambda (elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1493 (mapc (lambda (inner-elt)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1494 (setq info-list
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1495 (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
1496 (package-desc-vers
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1497 (cdr inner-elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1498 "obsolete"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1499 (package-desc-doc
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1500 (cdr inner-elt))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1501 info-list)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1502 (cdr elt)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1503 package-obsolete-alist)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1504
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1505 (setq info-list
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1506 (sort info-list
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1507 (cond ((string= package-menu-sort-key "Version")
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1508 'package-menu--version-predicate)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1509 ((string= package-menu-sort-key "Status")
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1510 'package-menu--status-predicate)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1511 ((string= package-menu-sort-key "Description")
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1512 'package-menu--description-predicate)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1513 (t ; Sort by package name by default
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1514 'package-menu--name-predicate))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1515
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1516 (dolist (elt info-list)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1517 (package-print-package (car (car elt))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1518 (cdr (car elt))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1519 (car (cdr elt))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1520 (car (cdr (cdr elt))))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1521 (goto-char (point-min))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1522 (set-buffer-modified-p nil)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1523 (current-buffer)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1524
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1525 (defun package-menu--version-predicate (left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1526 (let ((vleft (cdr (car left)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1527 (vright (cdr (car right))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1528 (if (version-list-= vleft right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1529 (package-menu--name-predicate left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1530 (version-list-< left right))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1531
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1532 (defun package-menu--status-predicate (left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1533 (let ((sleft (cadr left))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1534 (sright (cadr right)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1535 (cond ((string= sleft sright)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1536 (package-menu--name-predicate left right))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1537 ((string= sleft "available") t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1538 ((string= sright "available") nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1539 ((string= sleft "installed") t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1540 ((string= sright "installed") nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1541 ((string= sleft "held") t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1542 ((string= sright "held") nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1543 ((string= sleft "built-in") t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1544 ((string= sright "built-in") nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1545 ((string= sleft "obsolete") t)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1546 ((string= sright "obsolete") nil)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1547 (t (string< sleft sright)))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1548
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1549 (defun package-menu--description-predicate (left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1550 (let ((sleft (car (cddr left)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1551 (sright (car (cddr right))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1552 (if (string= sleft sright)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1553 (package-menu--name-predicate left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1554 (string< sleft sright))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1555
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1556 (defun package-menu--name-predicate (left right)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1557 (string< (symbol-name (caar left))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1558 (symbol-name (caar right))))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1559
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1560 (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
1561 "Sort the package menu by the last column clicked on."
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1562 (interactive "e")
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1563 (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
1564 (let* ((pos (event-start e))
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1565 (obj (posn-object pos))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1566 (col (if obj
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1567 (get-text-property (cdr obj) 'column-name (car obj))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1568 (get-text-property (posn-point pos) 'column-name)))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1569 (inhibit-read-only t))
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1570 (setq package-menu-sort-key col)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1571 (package--generate-package-list)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1572
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1573 (defun package--list-packages (&optional packages)
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1574 "Display the properties of PACKAGES.
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1575 PACKAGES should be a list of package names (symbols).
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1576 If PACKAGES is nil, display all packages in `package-alist'."
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1577 (with-current-buffer (package--generate-package-list packages)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1578 (package-menu-mode)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1579 ;; Set up the header line.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1580 (setq header-line-format
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1581 (mapconcat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1582 (lambda (pair)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1583 (let ((column (car pair))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1584 (name (cdr pair)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1585 (concat
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1586 ;; 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
1587 (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
1588 'face 'fixed-pitch)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1589 ;; Set up the column button.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1590 (if (string= name "Version")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1591 name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1592 (propertize name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1593 'column-name name
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1594 '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
1595 'mouse-face 'highlight
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1596 '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
1597 ;; 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
1598 ;; 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
1599 ;; 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
1600 ;; but it is close enough.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1601 '((0 . "")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1602 (2 . "Package")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1603 (20 . "Version")
109602
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1604 (32 . "Status")
a86a4e812897 Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
1605 (43 . "Description"))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1606 ""))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1607
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1608 ;; It's okay to use pop-to-buffer here. The package menu buffer
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1609 ;; has keybindings, and the user just typed `M-x list-packages',
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1610 ;; suggesting that they might want to use them.
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1611 (pop-to-buffer (current-buffer))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1612
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1613 ;;;###autoload
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1614 (defun list-packages ()
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1615 "Display a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1616 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
1617 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
1618 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1619 (package-refresh-contents)
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1620 (setq package-menu-sort-key "Status")
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1621 (package--list-packages))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1622
109970
77c4a65b9011 * emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
1623 ;;;###autoload
110017
10e66ac64b61 Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents: 109992
diff changeset
1624 (defalias 'package-list-packages 'list-packages)
109970
77c4a65b9011 * emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
1625
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1626 (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
1627 "Display a list of packages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1628 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
1629 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
1630 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1631 (package--list-packages))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1632
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1633 (provide 'package)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1634
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1635 ;;; package.el ends here