Mercurial > emacs
annotate lisp/emacs-lisp/package.el @ 111518:adbfcf85c8eb
* lisp/shell.el (shell-dir-cookie-re): New custom variable.
(shell-dir-cookie-watcher): New function.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 12 Nov 2010 09:13:48 -0500 |
parents | 59101ed2e4c6 |
children | b6c07b465755 |
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 ;; |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
80 ;; M-x list-packages |
109016
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)) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
218 (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
|
219 |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
220 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/")) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
221 "An alist of archives from which to fetch. |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
222 The default value points to the GNU Emacs package repository. |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
223 Each element has the form (ID . URL), where ID is an identifier |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
224 string for an archive and URL is a http: URL (a string)." |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
225 :type '(alist :key-type (string :tag "Archive name") |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
226 :value-type (string :tag "Archive URL")) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
227 :risky t |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
228 :group 'package |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
229 :version "24.1") |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 (defconst package-archive-version 1 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 "Version number of the package archive understood by this file. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 Lower version numbers than this will probably be understood as well.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 (defconst package-el-version "1.0" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 "Version of package.el.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 ;; We don't prime the cache since it tends to get out of date. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 (defvar package-archive-contents nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 "Cache of the contents of the Emacs Lisp Package Archive. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 This is an alist mapping package names (symbols) to package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 descriptor vectors. These are like the vectors for `package-alist' |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
243 but have extra entries: one which is 'tar for tar packages and |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
244 'single for single-file packages, and one which is the name of |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
245 the archive from which it came.") |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
246 (put 'package-archive-contents 'risky-local-variable t) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (defcustom package-user-dir (locate-user-emacs-file "elpa") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 "Directory containing the user's Emacs Lisp packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 The directory name should be absolute. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 Apart from this directory, Emacs also looks for system-wide |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 packages in `package-directory-list'." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 :type 'directory |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
254 :risky t |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 :group 'package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 :version "24.1") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 (defcustom package-directory-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 ;; Defaults are subdirs named "elpa" in the site-lisp dirs. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (let (result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (dolist (f load-path) |
110182
96ce91e806ec
* emacs-lisp/package.el (package-directory-list): Only call file-name-nondirectory on a string.
Chong Yidong <cyd@stupidchicken.com>
parents:
110181
diff
changeset
|
262 (and (stringp f) |
96ce91e806ec
* emacs-lisp/package.el (package-directory-list): Only call file-name-nondirectory on a string.
Chong Yidong <cyd@stupidchicken.com>
parents:
110181
diff
changeset
|
263 (equal (file-name-nondirectory f) "site-lisp") |
96ce91e806ec
* emacs-lisp/package.el (package-directory-list): Only call file-name-nondirectory on a string.
Chong Yidong <cyd@stupidchicken.com>
parents:
110181
diff
changeset
|
264 (push (expand-file-name "elpa" f) result))) |
109016
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. |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
280 The actual value is initialized by loading the library |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
281 `finder-inf'; this is not done until it is needed, e.g. by the |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
282 function `package-built-in-p'. |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
283 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
284 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
|
285 name (a symbol) and DESC is a vector that describes the package. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
286 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
|
287 VERSION is a version list. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
288 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
|
289 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
|
290 (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
|
291 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
292 (defvar package-alist nil |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 "Alist of all packages available for activation. |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
294 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
|
295 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
|
296 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
297 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
|
298 VERSION is a version list. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
299 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
|
300 DOCSTRING is a brief description of the package. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
301 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
302 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
|
303 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
|
304 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
|
305 (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
|
306 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
307 (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
|
308 "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
|
309 (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
|
310 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (defvar package-obsolete-alist nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 "Representation of obsolete packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 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
|
314 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
|
315 (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
|
316 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (defconst package-subdirectory-regexp |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 "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
|
320 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
|
321 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
|
322 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (defun package-version-join (l) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 "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
|
325 (mapconcat 'int-to-string l ".")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (defun package-strip-version (dirname) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 "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
|
329 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
|
330 (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
|
331 (match-string 1 dirname))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (defun package-load-descriptor (dir package) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
334 "Load the description file in directory DIR for package PACKAGE. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
335 Here, PACKAGE is a string of the form NAME-VER, where NAME is the |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
336 package name and VER is its version." |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
337 (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
|
338 (pkg-file (expand-file-name |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
339 (concat (package-strip-version package) "-pkg") |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
340 pkg-dir))) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
341 (when (and (file-directory-p pkg-dir) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
342 (file-exists-p (concat pkg-file ".el"))) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
343 (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
|
344 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (defun package-load-all-descriptors () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 "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
|
347 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
|
348 `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
|
349 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
|
350 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 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
|
352 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
|
353 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
|
354 (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
|
355 name version force) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (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
|
357 (when (file-directory-p dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (dolist (subdir (directory-files dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (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
|
360 (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
|
361 (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
|
362 version (match-string 2 subdir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 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
|
364 (when (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 ((null force) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 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
|
367 ((null (setq force (cadr force))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 nil) ; disabled |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ((eq force t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 ((stringp force) ; held |
109731
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
372 (version-list-= (version-to-list version) |
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
373 (version-to-list force))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (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
|
376 (package-load-descriptor dir subdir)))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (defsubst package-desc-vers (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 "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
|
380 (aref desc 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (defsubst package-desc-reqs (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 "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
|
384 (aref desc 1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (defsubst package-desc-doc (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 "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
|
388 (aref desc 2)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (defsubst package-desc-kind (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 "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
|
392 (aref desc 3)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
394 (defun package--dir (name version) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
395 "Return the directory where a package is installed, or nil if none. |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
396 NAME and VERSION are both strings." |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
397 (let* ((subdir (concat name "-" version)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 (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
|
399 pkg-dir) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 (while dir-list |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
401 (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
|
402 (if (file-directory-p subdir-full) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
403 (setq pkg-dir subdir-full |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
404 dir-list nil) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (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
|
406 pkg-dir)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
407 |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
408 (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
|
409 (let* ((name (symbol-name package)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
410 (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
|
411 (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
|
412 (unless pkg-dir |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
413 (error "Internal error: unable to find directory for `%s-%s'" |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
414 name version-str)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
415 ;; Add info node. |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
416 (when (file-exists-p (expand-file-name "dir" pkg-dir)) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
417 ;; FIXME: not the friendliest, but simple. |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
418 (require 'info) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
419 (info-initialize) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
420 (push pkg-dir Info-directory-list)) |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
421 ;; Add to load path, add autoloads, and activate the package. |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
422 (push pkg-dir load-path) |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
423 (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t) |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
424 (push package package-activated-list) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 ;; Don't return nil. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 t)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
428 (defun package-built-in-p (package &optional version) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
429 "Return true if PACKAGE, of VERSION or newer, is built-in to Emacs." |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
430 (require 'finder-inf nil t) ; For `package--builtins'. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 (let ((elt (assq package package--builtins))) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
432 (and elt (version-list-<= version (package-desc-vers (cdr elt)))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
434 ;; This function goes ahead and activates a newer version of a package |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
435 ;; if an older one was already activated. This is not ideal; we'd at |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
436 ;; least need to check to see if the package has actually been loaded, |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
437 ;; and not merely activated. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 (defun package-activate (package version) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
439 "Activate package PACKAGE, of version VERSION or newer. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
440 If PACKAGE has any dependencies, recursively activate them. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 Return nil if the package could not be activated." |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
442 (let ((pkg-vec (cdr (assq package package-alist))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
443 available-version found) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
444 ;; Check if PACKAGE is available in `package-alist'. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
445 (when pkg-vec |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
446 (setq available-version (package-desc-vers pkg-vec) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
447 found (version-list-<= version available-version))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
448 (cond |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
449 ;; If no such package is found, maybe it's built-in. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
450 ((null found) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
451 (package-built-in-p package version)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
452 ;; If the package is already activated, just return t. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
453 ((memq package package-activated-list) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
454 t) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
455 ;; Otherwise, proceed with activation. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
456 (t |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
457 (let ((fail (catch 'dep-failure |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
458 ;; Activate its dependencies recursively. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
459 (dolist (req (package-desc-reqs pkg-vec)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
460 (unless (package-activate (car req) (cadr req)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
461 (throw 'dep-failure req)))))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
462 (if fail |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
463 (warn "Unable to activate package `%s'. |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
464 Required package `%s-%s' is unavailable" |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
465 package (car fail) (package-version-join (cadr fail))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
466 ;; If all goes well, activate the package itself. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
467 (package-activate-1 package pkg-vec))))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 (defun package-mark-obsolete (package pkg-vec) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 "Put package on the obsolete list, if not already there." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 (let ((elt (assq package package-obsolete-alist))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 (if elt |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 ;; If this obsolete version does not exist in the list, update |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 ;; it the list. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 (unless (assoc (package-desc-vers pkg-vec) (cdr elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 (setcdr elt (cons (cons (package-desc-vers pkg-vec) pkg-vec) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 (cdr elt)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 ;; Make a new association. |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
479 (push (cons package (list (cons (package-desc-vers pkg-vec) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
480 pkg-vec))) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
481 package-obsolete-alist)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
483 (defun define-package (name-string version-string |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
484 &optional docstring requirements |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
485 &rest extra-properties) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 "Define a new package. |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
487 NAME-STRING is the name of the package, as a string. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
488 VERSION-STRING is the version of the package, as a list of |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
489 integers of the form produced by `version-to-list'. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
490 DOCSTRING is a short description of the package, a string. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
491 REQUIREMENTS is a list of dependencies on other packages. |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
492 Each requirement is of the form (OTHER-PACKAGE \"VERSION\"). |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
493 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
494 EXTRA-PROPERTIES is currently unused." |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
495 (let* ((name (intern name-string)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
496 (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
|
497 (new-pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 (cons name |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
499 (vector version |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (list (car elt) |
109731
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
503 (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
|
504 requirements) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
505 docstring))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
506 (old-pkg (assq name package-alist))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
507 (cond |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
508 ;; If there's no old package, just add this to `package-alist'. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
509 ((null old-pkg) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
510 (push new-pkg-desc package-alist)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
511 ((version-list-< (package-desc-vers (cdr old-pkg)) version) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
512 ;; Remove the old package and declare it obsolete. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
513 (package-mark-obsolete name (cdr old-pkg)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
514 (setq package-alist (cons new-pkg-desc |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
515 (delq old-pkg package-alist)))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
516 ;; You can have two packages with the same version, e.g. one in |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
517 ;; the system package directory and one in your private |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
518 ;; directory. We just let the first one win. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
519 ((not (version-list-= (package-desc-vers (cdr old-pkg)) version)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
520 ;; The package is born obsolete. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
521 (package-mark-obsolete name (cdr new-pkg-desc)))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 ;; From Emacs 22. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (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
|
525 "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
|
526 (unless (file-exists-p file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 (write-region |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 (concat ";;; " (file-name-nondirectory file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 " --- automatically extracted autoloads\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 ";;\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 ";;; Code:\n\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 "\n;; Local Variables:\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 ";; version-control: never\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 ";; no-byte-compile: t\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 ";; no-update-autoloads: t\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 ";; End:\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 ";;; " (file-name-nondirectory file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 " ends here\n") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 nil file)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 (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
|
543 (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
|
544 (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
|
545 (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
|
546 (version-control 'never)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 (require 'autoload) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 (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
|
549 (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
|
550 (update-directory-autoloads pkg-dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 (defun package-untar-buffer () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 "Untar the current buffer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 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
|
555 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
|
556 `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
|
557 (require 'tar-mode) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 (if (fboundp 'tar-untar-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 ;; 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
|
561 ;; whole buffer to play with. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (delete-region (point-min) (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 (tar-mode) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 (tar-untar-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 ;; FIXME: check the result. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (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
|
567 "xf" "-"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 (defun package-unpack (name version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 (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
|
571 package-user-dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 (make-directory package-user-dir t) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
573 ;; FIXME: should we delete PKG-DIR if it exists? |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (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
|
575 (package-untar-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (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
|
577 (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
|
578 (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
|
579 |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
580 (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
|
581 (let ((buffer-file-coding-system 'no-conversion)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
582 (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
|
583 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 (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
|
585 "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
|
586 ;; Special case "package". |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 (if (string= file-name "package") |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
588 (package--write-file-no-coding |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
589 (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
|
590 nil) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 (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
|
592 package-user-dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 (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
|
594 (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
|
595 (make-directory pkg-dir t) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
596 (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
|
597 (let ((print-level nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 (print-length nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 (write-region |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 (concat |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 (prin1-to-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (list 'define-package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 file-name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 (list 'quote |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 ;; 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
|
608 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 (list (car elt) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
611 (package-version-join (cadr elt)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 requires)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 "\n") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 pkg-file |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 nil nil nil 'excl)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 (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
|
618 (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
|
619 (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
|
620 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (defun package-handle-response () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 "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
|
623 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
|
624 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
|
625 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
|
626 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
|
627 ;; We assume HTTP here. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (require 'url-http) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (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
|
630 (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
|
631 (display-buffer (current-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (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
|
633 (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
|
634 (end-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (point))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (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
|
638 "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
|
639 (let ((buffer (url-retrieve-synchronously |
109580
3021343b766a
Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
109567
diff
changeset
|
640 (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
|
641 (symbol-name name) "-" version ".el")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 (with-current-buffer buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 (delete-region (point-min) (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 (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
|
648 (kill-buffer buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (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
|
651 "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
|
652 (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
|
653 (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
|
654 (symbol-name name) "-" version ".tar")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 (with-current-buffer tar-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 (package-unpack name version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 (kill-buffer tar-buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
662 (defun package-installed-p (package &optional min-version) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
663 "Return true if PACKAGE, of VERSION or newer, is installed. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
664 Built-in packages also qualify." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (let ((pkg-desc (assq package package-alist))) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
666 (if pkg-desc |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
667 (version-list-<= min-version |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
668 (package-desc-vers (cdr pkg-desc))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
669 ;; Also check built-in packages. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
670 (package-built-in-p package min-version)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
672 (defun package-compute-transaction (package-list requirements) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
673 "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
|
674 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
|
675 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
676 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
|
677 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
|
678 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
|
679 version of that package (as a list). |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
680 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
681 This function recursively computes the requirements of the |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
682 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
|
683 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
|
684 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
|
685 (dolist (elt requirements) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (let* ((next-pkg (car elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (next-version (cadr elt))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (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
|
689 ;; 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
|
690 ;; blocked via `package-load-list'. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 (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
|
692 hold) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 (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
|
694 (setq hold (cadr hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (cond ((eq hold nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (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
|
697 (symbol-name next-pkg))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 ((null (stringp hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (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
|
700 ((version-list-< (version-to-list hold) next-version) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
701 (error "Package `%s' held at version %s, \ |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 but version %s required" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (symbol-name next-pkg) hold |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 (package-version-join next-version))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 (unless pkg-desc |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
706 (error "Package `%s-%s' is unavailable" |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
707 (symbol-name next-pkg) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
708 (package-version-join next-version))) |
109731
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
709 (unless (version-list-<= next-version |
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
710 (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
|
711 (error |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
712 "Need package `%s-%s', but only %s is available" |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (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
|
714 (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
|
715 ;; 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
|
716 (unless (memq next-pkg package-list) |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
717 (push next-pkg package-list)) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
718 (setq package-list |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
719 (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
|
720 (package-desc-reqs |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 (cdr pkg-desc)))))))) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
722 package-list) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (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
|
725 "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
|
726 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
|
727 (let* ((read-data (read-from-string str)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
728 (more-left |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
729 (condition-case nil |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
730 ;; The call to `ignore' suppresses a compiler warning. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
731 (progn (ignore (read-from-string |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
732 (substring str (cdr read-data)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
733 t) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
734 (end-of-file nil)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (if more-left |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (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
|
737 (car read-data)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 (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
|
740 "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
|
741 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
|
742 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
|
743 (let ((filename (expand-file-name file package-user-dir))) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
744 (when (file-exists-p filename) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
745 (with-temp-buffer |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
746 (insert-file-contents-literally filename) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
747 (let ((contents (read (current-buffer)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
748 (if (> (car contents) package-archive-version) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
749 (error "Package archive version %d is higher than %d" |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
750 (car contents) package-archive-version)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
751 (cdr contents)))))) |
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-all-archive-contents () |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
754 "Re-read `archive-contents', if it exists. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
755 If successful, set `package-archive-contents'." |
111477
59101ed2e4c6
Minor fix to package-archive-contents recalculation.
Chong Yidong <cyd@stupidchicken.com>
parents:
111394
diff
changeset
|
756 (setq package-archive-contents nil) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
757 (dolist (archive package-archives) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
758 (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
|
759 |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
760 (defun package-read-archive-contents (archive) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
761 "Re-read archive contents for ARCHIVE. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
762 If successful, set the variable `package-archive-contents'. |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
763 If the archive version is too new, signal an error." |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
764 ;; Version 1 of 'archive-contents' is identical to our internal |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
765 ;; representation. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
766 (let* ((dir (concat "archives/" archive)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
767 (contents-file (concat dir "/archive-contents")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
768 contents) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
769 (when (setq contents (package--read-archive-file contents-file)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
770 (dolist (package contents) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
771 (package--add-to-archive-contents package archive))))) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
772 |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
773 (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
|
774 "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
|
775 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
|
776 (let* ((name (car package)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
777 (version (aref (cdr package) 0)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
778 (entry (cons (car package) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
779 (vconcat (cdr package) (vector archive)))) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
780 (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
|
781 (when (or (not existing-package) |
109731
01af31a38d9e
Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
109602
diff
changeset
|
782 (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
|
783 (add-to-list 'package-archive-contents entry)))) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
784 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
785 (defun package-download-transaction (package-list) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
786 "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
|
787 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
|
788 This function assumes that all package requirements in |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
789 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
|
790 using `package-compute-transaction'." |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
791 (dolist (elt package-list) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (let* ((desc (cdr (assq elt package-archive-contents))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 ;; As an exception, if package is "held" in |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 ;; `package-load-list', download the held version. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 (hold (cadr (assq elt package-load-list))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (v-string (or (and (stringp hold) hold) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 (package-version-join (package-desc-vers desc)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (kind (package-desc-kind desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 ((eq kind 'tar) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (package-download-tar elt v-string)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 ((eq kind 'single) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 (package-download-single elt v-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 (package-desc-doc desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 (package-desc-reqs desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 (error "Unknown package kind: %s" (symbol-name kind))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 (defun package-install (name) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 "Install the package named NAME. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 Interactively, prompt for the package name. |
109580
3021343b766a
Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
109567
diff
changeset
|
813 The package is found on one of the archives in `package-archives'." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (interactive |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
815 (list (intern (completing-read "Install package: " |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
816 (mapcar (lambda (elt) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
817 (cons (symbol-name (car elt)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
818 nil)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
819 package-archive-contents) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
820 nil t)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (let ((pkg-desc (assq name package-archive-contents))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 (unless pkg-desc |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
823 (error "Package `%s' is not available for installation" |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 (symbol-name name))) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
825 (package-download-transaction |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
826 (package-compute-transaction (list name) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
827 (package-desc-reqs (cdr pkg-desc))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 ;; Try to activate it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (package-initialize)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (defun package-strip-rcs-id (v-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 "Strip RCS version ID from the version string. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 If the result looks like a dotted numeric version, return it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 Otherwise return nil." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 (if v-str |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (if (string-match "^[ \t]*[$]Revision:[ \t]\([0-9.]+\)[ \t]*[$]$" v-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (match-string 1 v-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 (if (string-match "^[0-9.]*$" v-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 v-str)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 (defun package-buffer-info () |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
842 "Return a vector describing the package in the current buffer. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
843 The vector has the form |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
844 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
845 [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY] |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
846 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
847 FILENAME is the file name, a string, sans the \".el\" extension. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 REQUIRES is a requires list, or nil. |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
849 DESCRIPTION is the package description, a string. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 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
|
851 COMMENTARY is the commentary section, a string, or nil if none. |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
852 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
853 If the buffer does not contain a conforming package, signal an |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
854 error. If there is a package, narrow the buffer to the file's |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
855 boundaries." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 (goto-char (point-min)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
857 (unless (re-search-forward "^;;; \\([^ ]*\\)\\.el --- \\(.*\\)$" nil t) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
858 (error "Packages lacks a file header")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
859 (let ((file-name (match-string-no-properties 1)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
860 (desc (match-string-no-properties 2)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
861 (start (line-beginning-position))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
862 (unless (search-forward (concat ";;; " file-name ".el ends here")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
863 (error "Package lacks a terminating comment")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
864 ;; Try to include a trailing newline. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
865 (forward-line) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
866 (narrow-to-region start (point)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
867 (require 'lisp-mnt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
868 ;; Use some headers we've invented to drive the process. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
869 (let* ((requires-str (lm-header "package-requires")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
870 (requires (if requires-str |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
871 (package-read-from-string requires-str))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
872 ;; Prefer Package-Version; if defined, the package author |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
873 ;; probably wants us to use it. Otherwise try Version. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
874 (pkg-version |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
875 (or (package-strip-rcs-id (lm-header "package-version")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
876 (package-strip-rcs-id (lm-header "version")))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
877 (commentary (lm-commentary))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
878 (unless pkg-version |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
879 (error |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
880 "Package lacks a \"Version\" or \"Package-Version\" header")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
881 ;; Turn string version numbers into list form. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
882 (setq requires |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
883 (mapcar |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
884 (lambda (elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
885 (list (car elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
886 (version-to-list (car (cdr elt))))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
887 requires)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
888 (vector file-name requires desc pkg-version commentary)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 (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
|
891 "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
|
892 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
|
893 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
|
894 (unless (string-match "^\\(.+\\)-\\([0-9.]+\\)\\.tar$" file) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
895 (error "Invalid package name `%s'" file)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 (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
|
897 (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
|
898 ;; Extract the package descriptor. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 (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
|
900 ;; Requires GNU tar. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 (concat "tar -xOf " file " " |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 pkg-name "-" pkg-version "/" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 pkg-name "-pkg.el"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 (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
|
905 (unless (eq (car pkg-def-parsed) 'define-package) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
906 (error "No `define-package' sexp is present in `%s-pkg.el'" pkg-name)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
907 (let ((name-str (nth 1 pkg-def-parsed)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 (version-string (nth 2 pkg-def-parsed)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
909 (docstring (nth 3 pkg-def-parsed)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
910 (requires (nth 4 pkg-def-parsed)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 (readme (shell-command-to-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 ;; Requires GNU tar. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 (concat "tar -xOf " file " " |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 pkg-name "-" pkg-version "/README")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 (unless (equal pkg-version version-string) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
916 (error "Package has inconsistent versions")) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 (unless (equal pkg-name name-str) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
918 (error "Package has inconsistent names")) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 ;; Kind of a hack. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 (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
|
921 (setq readme nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 ;; 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
|
923 (if (eq (car requires) 'quote) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 (setq requires (car (cdr requires)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 (setq requires |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
926 (mapcar (lambda (elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
927 (list (car elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
928 (version-to-list (cadr elt)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
929 requires)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (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
|
931 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
932 ;;;###autoload |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
933 (defun package-install-from-buffer (pkg-info type) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
934 "Install a package from the current buffer. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
935 When called interactively, the current buffer is assumed to be a |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
936 single .el file that follows the packaging guidelines; see info |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
937 node `(elisp)Packaging'. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
938 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
939 When called from Lisp, PKG-INFO is a vector describing the |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
940 information, of the type returned by `package-buffer-info'; and |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
941 TYPE is the package type (either `single' or `tar')." |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
942 (interactive (list (package-buffer-info) 'single)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 (save-restriction |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 (let* ((file-name (aref pkg-info 0)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
946 (requires (aref pkg-info 1)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 (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
|
948 "No description available." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 (aref pkg-info 2))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 (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
|
951 ;; Download and install the dependencies. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 (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
|
953 (package-download-transaction transaction)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 ;; Install the package itself. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 ((eq type 'single) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 (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
|
958 ((eq type 'tar) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 (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
|
960 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 (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
|
962 ;; Try to activate it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 (package-initialize))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
965 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (defun package-install-file (file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 "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
|
968 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
|
969 (interactive "fPackage file name: ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 (with-temp-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 (insert-file-contents-literally file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 (cond |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
973 ((string-match "\\.el$" file) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
974 (package-install-from-buffer (package-buffer-info) 'single)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 ((string-match "\\.tar$" file) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
976 (package-install-from-buffer (package-tar-file-info file) 'tar)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 (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
|
978 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 (defun package-delete (name version) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
980 (let ((dir (package--dir name version))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
981 (if (string-equal (file-name-directory dir) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
982 (file-name-as-directory |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
983 (expand-file-name package-user-dir))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
984 (progn |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
985 (delete-directory dir t t) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
986 (message "Package `%s-%s' deleted." name version)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
987 ;; Don't delete "system" packages |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
988 (error "Package `%s-%s' is a system package, not deleting" |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
989 name version)))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 |
109580
3021343b766a
Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents:
109567
diff
changeset
|
991 (defun package-archive-url (name) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
992 "Return the archive containing the package NAME." |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
993 (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
|
994 (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
|
995 |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
996 (defun package--download-one-archive (archive file) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
997 "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
|
998 (let* ((archive-name (car archive)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
999 (archive-url (cdr archive)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
1000 (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
|
1001 (dir (expand-file-name archive-name dir)) |
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
1002 (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
|
1003 (with-current-buffer buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1005 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1006 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 (delete-region (point-min) (point)) |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1008 ;; Read the retrieved buffer to make sure it is valid (e.g. it |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1009 ;; may fetch a URL redirect page). |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1010 (when (listp (read buffer)) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1011 (make-directory dir t) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1012 (setq buffer-file-name (expand-file-name file dir)) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1013 (let ((version-control 'never)) |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1014 (save-buffer)))) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
1015 (kill-buffer buffer))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1016 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1017 (defun package-refresh-contents () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1018 "Download the ELPA archive description if needed. |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1019 This informs Emacs about the latest versions of all packages, and |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1020 makes them available for download." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1021 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1022 (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
|
1023 (make-directory package-user-dir t)) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
1024 (dolist (archive package-archives) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1025 (condition-case nil |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1026 (package--download-one-archive archive "archive-contents") |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1027 (error (message "Failed to download `%s' archive." |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1028 (car archive))))) |
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 |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1031 (defvar package--initialized nil) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1032 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 ;;;###autoload |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1034 (defun package-initialize (&optional no-activate) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 "Load Emacs Lisp packages, and activate them. |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1036 The variable `package-load-list' controls which packages to load. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1037 If optional arg NO-ACTIVATE is non-nil, don't activate packages." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 (interactive) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1039 (setq package-alist nil |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1040 package-obsolete-alist nil) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 (package-load-all-descriptors) |
109567
0fc9f7a0d319
Add support for non-default package repositories.
Chong Yidong <cyd@stupidchicken.com>
parents:
109027
diff
changeset
|
1042 (package-read-all-archive-contents) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1043 (unless no-activate |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1044 (dolist (elt package-alist) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1045 (package-activate (car elt) (package-desc-vers (cdr elt))))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1046 (setq package--initialized t)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1049 ;;;; Package description buffer. |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1051 ;;;###autoload |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1052 (defun describe-package (package) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1053 "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
|
1054 (interactive |
111244
6a10cca95d2b
Check more carefully for packages before loading package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
111142
diff
changeset
|
1055 (let* ((guess (function-called-at-point)) |
6a10cca95d2b
Check more carefully for packages before loading package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
111142
diff
changeset
|
1056 packages val) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1057 (require 'finder-inf nil t) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1058 ;; Load the package list if necessary (but don't activate them). |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1059 (unless package--initialized |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1060 (package-initialize t)) |
111244
6a10cca95d2b
Check more carefully for packages before loading package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
111142
diff
changeset
|
1061 (setq packages (append (mapcar 'car package-alist) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1062 (mapcar 'car package-archive-contents) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1063 (mapcar 'car package--builtins))) |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1064 (unless (memq guess packages) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1065 (setq guess nil)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1066 (setq packages (mapcar 'symbol-name packages)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1067 (setq val |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1068 (completing-read (if guess |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1069 (format "Describe package (default %s): " |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1070 guess) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1071 "Describe package: ") |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1072 packages nil t nil nil guess)) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1073 (list (if (equal val "") guess (intern val))))) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1074 (if (or (null package) (not (symbolp package))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1075 (message "No package specified") |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1076 (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
|
1077 (called-interactively-p 'interactive)) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1078 (with-help-window (help-buffer) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1079 (with-current-buffer standard-output |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1080 (describe-package-1 package))))) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1081 |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1082 (defun describe-package-1 (package) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1083 (require 'lisp-mnt) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1084 (let ((package-name (symbol-name package)) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1085 (built-in (assq package package--builtins)) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1086 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
|
1087 (prin1 package) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1088 (princ " is ") |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1089 (cond |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1090 ;; Loaded packages are in `package-alist'. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1091 ((setq desc (cdr (assq package package-alist))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1092 (setq version (package-version-join (package-desc-vers desc))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1093 (if (setq pkg-dir (package--dir package-name version)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1094 (insert "an installed package.\n\n") |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1095 ;; This normally does not happen. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1096 (insert "a deleted package.\n\n"))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1097 ;; Available packages are in `package-archive-contents'. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1098 ((setq desc (cdr (assq package package-archive-contents))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1099 (setq version (package-version-join (package-desc-vers desc)) |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1100 installable t) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1101 (if built-in |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1102 (insert "a built-in package.\n\n") |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1103 (insert "an uninstalled package.\n\n"))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1104 (built-in |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1105 (setq desc (cdr built-in) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1106 version (package-version-join (package-desc-vers desc))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1107 (insert "a built-in package.\n\n")) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1108 (t |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1109 (insert "an orphan package.\n\n"))) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1110 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1111 (insert " " (propertize "Status" 'font-lock-face 'bold) ": ") |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1112 (cond (pkg-dir |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1113 (insert (propertize "Installed" |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1114 'font-lock-face 'font-lock-comment-face)) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1115 (insert " in `") |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1116 ;; Todo: Add button for uninstalling. |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1117 (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
|
1118 'help-package-def pkg-dir) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1119 (if built-in |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1120 (insert "',\n shadowing a " |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1121 (propertize "built-in package" |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1122 'font-lock-face 'font-lock-builtin-face) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1123 ".") |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1124 (insert "'."))) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1125 (installable |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1126 (if built-in |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1127 (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1128 " Alternate version available -- ") |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1129 (insert "Available -- ")) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1130 (let ((button-text (if (display-graphic-p) "Install" "[Install]")) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1131 (button-face (if (display-graphic-p) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1132 '(:box (:line-width 2 :color "dark grey") |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1133 :background "light grey" |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1134 :foreground "black") |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1135 'link))) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1136 (insert-text-button button-text 'face button-face 'follow-link t |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1137 'package-symbol package |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1138 'action 'package-install-button-action))) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1139 (built-in |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1140 (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face))) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1141 (t (insert "Deleted."))) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1142 (insert "\n") |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1143 (and version (> (length version) 0) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1144 (insert " " |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1145 (propertize "Version" 'font-lock-face 'bold) ": " version "\n")) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1146 |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1147 (setq reqs (if desc (package-desc-reqs desc))) |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1148 (when reqs |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1149 (insert " " (propertize "Requires" 'font-lock-face 'bold) ": ") |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1150 (let ((first t) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1151 name vers text) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1152 (dolist (req reqs) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1153 (setq name (car req) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1154 vers (cadr req) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1155 text (format "%s-%s" (symbol-name name) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1156 (package-version-join vers))) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1157 (cond (first (setq first nil)) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1158 ((>= (+ 2 (current-column) (length text)) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1159 (window-width)) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1160 (insert ",\n ")) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1161 (t (insert ", "))) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1162 (help-insert-xref-button text 'help-package name)) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1163 (insert "\n"))) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1164 (insert " " (propertize "Summary" 'font-lock-face 'bold) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1165 ": " (if desc (package-desc-doc desc)) "\n\n") |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1166 |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1167 (if built-in |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1168 ;; For built-in packages, insert the commentary. |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1169 (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
|
1170 load-file-rep-suffixes)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1171 (opoint (point))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1172 (insert (or (lm-commentary fn) "")) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1173 (save-excursion |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1174 (goto-char opoint) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1175 (when (re-search-forward "^;;; Commentary:\n" nil t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1176 (replace-match "")) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1177 (while (re-search-forward "^\\(;+ ?\\)" nil t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1178 (replace-match "")))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1179 (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
|
1180 package-user-dir))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1181 ;; 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
|
1182 ;; 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
|
1183 (cond ((let ((buffer (ignore-errors |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1184 (url-retrieve-synchronously |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1185 (concat (package-archive-url package) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1186 package-name "-readme.txt")))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1187 response) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1188 (when buffer |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1189 (with-current-buffer buffer |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1190 (setq response (url-http-parse-response)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1191 (if (or (< response 200) (>= response 300)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1192 (setq response nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1193 (setq buffer-file-name |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1194 (expand-file-name readme package-user-dir)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1195 (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
|
1196 (save-buffer))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1197 (when response |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1198 (insert-buffer-substring buffer) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1199 (kill-buffer buffer) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1200 t)))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1201 ((file-readable-p readme) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1202 (insert-file-contents readme) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1203 (goto-char (point-max)))))))) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1204 |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1205 (defun package-install-button-action (button) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1206 (let ((package (button-get button 'package-symbol))) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1207 (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
|
1208 (package-install package) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1209 (revert-buffer nil t) |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1210 (goto-char (point-min))))) |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1211 |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109020
diff
changeset
|
1212 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1213 ;;;; Package menu mode. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1214 |
109018
3fa4756bb7be
emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents:
109016
diff
changeset
|
1215 (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
|
1216 (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
|
1217 (menu-map (make-sparse-keymap "Package"))) |
111142
947164fbfa46
* package.el (package-menu-mode-map): Inherit from button-buffer-map.
Chong Yidong <cyd@stupidchicken.com>
parents:
111141
diff
changeset
|
1218 (set-keymap-parent map button-buffer-map) |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1219 (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
|
1220 (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
|
1221 (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
|
1222 (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
|
1223 (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
|
1224 (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
|
1225 (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
|
1226 (define-key map "i" 'package-menu-mark-install) |
110153
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1227 (define-key map "g" 'revert-buffer) |
109018
3fa4756bb7be
emacs-lisp/package.el (package-menu-mode-map): Move initialization into declaration.
Juanma Barranquero <lekktu@gmail.com>
parents:
109016
diff
changeset
|
1228 (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
|
1229 (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
|
1230 (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
|
1231 (define-key map "h" 'package-menu-quick-help) |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1232 (define-key map "?" 'package-menu-describe-package) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1233 (define-key map [follow-link] 'mouse-face) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1234 (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
|
1235 (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
|
1236 (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
|
1237 '(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
|
1238 :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
|
1239 (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
|
1240 (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
|
1241 '(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
|
1242 :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
|
1243 (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
|
1244 '(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
|
1245 :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
|
1246 (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
|
1247 (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
|
1248 '(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
|
1249 :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
|
1250 (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
|
1251 '(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
|
1252 :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
|
1253 (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
|
1254 '(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
|
1255 :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
|
1256 (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
|
1257 '(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
|
1258 :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
|
1259 (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
|
1260 (define-key menu-map [mg] |
110153
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1261 '(menu-item "Update package list" revert-buffer |
109020
9087d6113b47
* lisp/emacs-lisp/package.el (package-menu-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109018
diff
changeset
|
1262 :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
|
1263 (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
|
1264 '(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
|
1265 :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
|
1266 (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
|
1267 (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
|
1268 '(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
|
1269 :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
|
1270 (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
|
1271 '(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
|
1272 :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
|
1273 (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
|
1274 (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
|
1275 '(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
|
1276 :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
|
1277 (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
|
1278 '(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
|
1279 :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
|
1280 map) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1281 "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
|
1282 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1283 (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
|
1284 (let ((map (make-sparse-keymap))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1285 (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
|
1286 (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
|
1287 (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
|
1288 map) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1289 "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
|
1290 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1291 (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
|
1292 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1293 (defun package-menu-mode () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1294 "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
|
1295 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
|
1296 \\<package-menu-mode-map> |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1297 \\{package-menu-mode-map}" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1298 (kill-all-local-variables) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1299 (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
|
1300 (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
|
1301 (setq mode-name "Package Menu") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1302 (setq truncate-lines t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1303 (setq buffer-read-only t) |
110473 | 1304 (set (make-local-variable 'revert-buffer-function) 'package-menu-revert) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1305 (setq header-line-format |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1306 (mapconcat |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1307 (lambda (pair) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1308 (let ((column (car pair)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1309 (name (cdr pair))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1310 (concat |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1311 ;; Insert a space that aligns the button properly. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1312 (propertize " " 'display (list 'space :align-to column) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1313 'face 'fixed-pitch) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1314 ;; Set up the column button. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1315 (propertize name |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1316 'column-name name |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1317 'help-echo "mouse-1: sort by column" |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1318 'mouse-face 'highlight |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1319 'keymap package-menu-sort-button-map)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1320 ;; We take a trick from buff-menu and have a dummy leading |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1321 ;; space to align the header line with the beginning of the |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1322 ;; text. This doesn't really work properly on Emacs 21, but |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1323 ;; it is close enough. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1324 '((0 . "") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1325 (2 . "Package") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1326 (20 . "Version") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1327 (32 . "Status") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1328 (43 . "Description")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1329 "")) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1330 (run-mode-hooks 'package-menu-mode-hook)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1331 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1332 (defun package-menu-refresh () |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1333 "Download the Emacs Lisp package archive. |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1334 This fetches the contents of each archive specified in |
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1335 `package-archives', and then refreshes the package menu." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1336 (interactive) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1337 (unless (eq major-mode 'package-menu-mode) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1338 (error "The current buffer is not a Package Menu")) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1339 (package-refresh-contents) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1340 (package--generate-package-list)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1341 |
110153
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1342 (defun package-menu-revert (&optional arg noconfirm) |
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1343 "Update the list of packages. |
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1344 This function is the `revert-buffer-function' for Package Menu |
b071d3abc3f4
Set revert-buffer-function in Package Menu.
Chong Yidong <cyd@stupidchicken.com>
parents:
110056
diff
changeset
|
1345 buffers. The arguments are ignored." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1346 (interactive) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1347 (unless (eq major-mode 'package-menu-mode) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1348 (error "The current buffer is not a Package Menu")) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1349 (package--generate-package-list)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1350 |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1351 (defun package-menu-describe-package () |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1352 "Describe the package in the current line." |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1353 (interactive) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1354 (let ((name (package-menu-get-package))) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1355 (if name |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1356 (describe-package (intern name)) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1357 (message "No package on this line")))) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1358 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1359 (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
|
1360 (unless (eobp) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1361 (let ((buffer-read-only nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1362 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1363 (delete-char 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1364 (insert what) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1365 (forward-line)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1366 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1367 ;; fixme numeric argument |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1368 (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
|
1369 "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
|
1370 (interactive "p") |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1371 (if (string-equal (package-menu-get-status) "installed") |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1372 (package-menu-mark-internal "D") |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1373 (forward-line))) |
109016
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 (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
|
1376 "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
|
1377 (interactive "p") |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1378 (if (string-equal (package-menu-get-status) "available") |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1379 (package-menu-mark-internal "I") |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1380 (forward-line))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1381 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1382 (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
|
1383 "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
|
1384 (interactive "p") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1385 (package-menu-mark-internal " ")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1386 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1387 (defun package-menu-backup-unmark () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1388 "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
|
1389 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1390 (forward-line -1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1391 (package-menu-mark-internal " ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1392 (forward-line -1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1393 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1394 (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
|
1395 "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
|
1396 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1397 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1398 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1399 (forward-line 2) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1400 (while (not (eobp)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1401 (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
|
1402 (package-menu-mark-internal "D") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1403 (forward-line 1))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1404 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1405 (defun package-menu-quick-help () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1406 "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
|
1407 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1408 (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
|
1409 |
109992
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1410 (define-obsolete-function-alias |
640cdeb464c1
Improvements to describe-package buffer.
Chong Yidong <cyd@stupidchicken.com>
parents:
109970
diff
changeset
|
1411 '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
|
1412 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1413 ;; 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
|
1414 (defun package-menu-get-package () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1415 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1416 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1417 (if (looking-at ". \\([^ \t]*\\)") |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1418 (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
|
1419 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1420 ;; 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
|
1421 (defun package-menu-get-version () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1422 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1423 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1424 (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
|
1425 (match-string 1)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1426 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1427 (defun package-menu-get-status () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1428 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1429 (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
|
1430 (match-string 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1431 ""))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1432 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1433 (defun package-menu-execute () |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1434 "Perform marked Package Menu actions. |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1435 Packages marked for installation are downloaded and installed; |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1436 packages marked for deletion are removed." |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1437 (interactive) |
111394
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1438 (let (install-list delete-list cmd) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1439 (save-excursion |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1440 (goto-char (point-min)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1441 (while (not (eobp)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1442 (setq cmd (char-after)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1443 (cond |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1444 ((eq cmd ?\s) t) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1445 ((eq cmd ?D) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1446 (push (cons (package-menu-get-package) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1447 (package-menu-get-version)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1448 delete-list)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1449 ((eq cmd ?I) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1450 (push (package-menu-get-package) install-list))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1451 (forward-line))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1452 ;; Delete packages, prompting if necessary. |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1453 (when delete-list |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1454 (if (yes-or-no-p |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1455 (if (= (length delete-list) 1) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1456 (format "Delete package `%s-%s'? " |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1457 (caar delete-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1458 (cdr (car delete-list))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1459 (format "Delete these %d packages (%s)? " |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1460 (length delete-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1461 (mapconcat (lambda (elt) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1462 (concat (car elt) "-" (cdr elt))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1463 delete-list |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1464 ", ")))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1465 (dolist (elt delete-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1466 (condition-case err |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1467 (package-delete (car elt) (cdr elt)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1468 (error (message (cadr err))))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1469 (error "Aborted"))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1470 (when install-list |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1471 (if (yes-or-no-p |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1472 (if (= (length install-list) 1) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1473 (format "Install package `%s'? " (car install-list)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1474 (format "Install these %d packages (%s)? " |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1475 (length install-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1476 (mapconcat 'identity install-list ", ")))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1477 (dolist (elt install-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1478 (package-install (intern elt))))) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1479 ;; If we deleted anything, regenerate `package-alist'. This is done |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1480 ;; automatically if we installed a package. |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1481 (and delete-list (null install-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1482 (package-initialize)) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1483 (if (or delete-list install-list) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1484 (package-menu-revert) |
72d2a83a2641
* emacs-lisp/package.el (package-unpack): Remove no-op.
Chong Yidong <cyd@stupidchicken.com>
parents:
111327
diff
changeset
|
1485 (message "No operations specified.")))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1486 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1487 (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
|
1488 (let ((face |
109602
a86a4e812897
Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents:
109580
diff
changeset
|
1489 (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
|
1490 ((string= key "available") 'default) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1491 ((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
|
1492 ((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
|
1493 ((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
|
1494 (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
|
1495 'font-lock-warning-face)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1496 (insert (propertize " " 'font-lock-face face)) |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1497 (insert-text-button (symbol-name package) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1498 'face 'link |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1499 'follow-link t |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1500 'package-symbol package |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1501 'action (lambda (button) |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1502 (describe-package |
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1503 (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
|
1504 (indent-to 20 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1505 (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
|
1506 (indent-to 32 1) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1507 (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
|
1508 ;; FIXME: this 'when' is bogus... |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1509 (when desc |
109027
858e3e43cfd5
Tweaks to package list UI.
Chong Yidong <cyd@stupidchicken.com>
parents:
109026
diff
changeset
|
1510 (indent-to 43 1) |
109602
a86a4e812897
Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents:
109580
diff
changeset
|
1511 (let ((opoint (point))) |
a86a4e812897
Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents:
109580
diff
changeset
|
1512 (insert (propertize desc 'font-lock-face face)) |
a86a4e812897
Package listing tweaks.
Chong Yidong <cyd@stupidchicken.com>
parents:
109580
diff
changeset
|
1513 (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
|
1514 (insert "\n"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1515 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1516 (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
|
1517 (unless (assoc (cons package version) result) |
110181
9e17fce46124
Avoid corrupting archive-contents file.
Chong Yidong <cyd@stupidchicken.com>
parents:
110153
diff
changeset
|
1518 (push (list (cons package version) status description) result)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1519 result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1520 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1521 (defvar package-menu-package-list nil |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1522 "List of packages to display in the Package Menu buffer. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1523 A value of nil means to display all packages.") |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1524 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1525 (defvar package-menu-sort-key nil |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1526 "Sort key for the current Package Menu buffer.") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1527 |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1528 (defun package--generate-package-list () |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1529 "Populate the current Package Menu buffer." |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1530 (let ((inhibit-read-only t) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1531 info-list name desc hold builtin) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1532 (erase-buffer) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1533 ;; List installed packages |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1534 (dolist (elt package-alist) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1535 (setq name (car elt)) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1536 (when (or (null package-menu-package-list) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1537 (memq name package-menu-package-list)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1538 (setq desc (cdr elt) |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1539 hold (cadr (assq name package-load-list))) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1540 (setq info-list |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1541 (package-list-maybe-add |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1542 name (package-desc-vers desc) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1543 ;; FIXME: it turns out to be tricky to see if this |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1544 ;; package is presently activated. |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1545 (if (stringp hold) "held" "installed") |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1546 (package-desc-doc desc) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1547 info-list)))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1548 |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1549 ;; List built-in packages |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1550 (dolist (elt package--builtins) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1551 (setq name (car elt)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1552 (when (and (not (eq name 'emacs)) ; Hide the `emacs' package. |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1553 (or (null package-menu-package-list) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1554 (memq name package-menu-package-list))) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1555 (setq desc (cdr elt)) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1556 (setq info-list |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1557 (package-list-maybe-add |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1558 name (package-desc-vers desc) |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1559 "built-in" |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1560 (package-desc-doc desc) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1561 info-list)))) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1562 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1563 ;; List available and disabled packages |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1564 (dolist (elt package-archive-contents) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1565 (setq name (car elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1566 desc (cdr elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1567 hold (assq name package-load-list)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1568 (when (or (null package-menu-package-list) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1569 (memq name package-menu-package-list)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1570 (setq info-list |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1571 (package-list-maybe-add name |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1572 (package-desc-vers desc) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1573 (if (and hold (null (cadr hold))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1574 "disabled" |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1575 "available") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1576 (package-desc-doc (cdr elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1577 info-list)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1578 ;; List obsolete packages |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1579 (mapc (lambda (elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1580 (mapc (lambda (inner-elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1581 (setq info-list |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1582 (package-list-maybe-add (car elt) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1583 (package-desc-vers |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1584 (cdr inner-elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1585 "obsolete" |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1586 (package-desc-doc |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1587 (cdr inner-elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1588 info-list))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1589 (cdr elt))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1590 package-obsolete-alist) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1591 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1592 (setq info-list |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1593 (sort info-list |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1594 (cond ((string= package-menu-sort-key "Package") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1595 'package-menu--name-predicate) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1596 ((string= package-menu-sort-key "Version") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1597 'package-menu--version-predicate) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1598 ((string= package-menu-sort-key "Description") |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1599 'package-menu--description-predicate) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1600 (t ; By default, sort by package status |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1601 'package-menu--status-predicate)))) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1602 |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1603 (dolist (elt info-list) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1604 (package-print-package (car (car elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1605 (cdr (car elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1606 (car (cdr elt)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1607 (car (cdr (cdr elt))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1608 (goto-char (point-min)) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1609 (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
|
1610 (current-buffer))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1611 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1612 (defun package-menu--version-predicate (left right) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1613 (let ((vleft (or (cdr (car left)) '(0))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1614 (vright (or (cdr (car right)) '(0)))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1615 (if (version-list-= vleft vright) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1616 (package-menu--name-predicate left right) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1617 (version-list-< vleft vright)))) |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1618 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1619 (defun package-menu--status-predicate (left right) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1620 (let ((sleft (cadr left)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1621 (sright (cadr right))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1622 (cond ((string= sleft sright) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1623 (package-menu--name-predicate left right)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1624 ((string= sleft "available") t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1625 ((string= sright "available") nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1626 ((string= sleft "installed") t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1627 ((string= sright "installed") nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1628 ((string= sleft "held") t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1629 ((string= sright "held") nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1630 ((string= sleft "built-in") t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1631 ((string= sright "built-in") nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1632 ((string= sleft "obsolete") t) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1633 ((string= sright "obsolete") nil) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1634 (t (string< sleft sright))))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1635 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1636 (defun package-menu--description-predicate (left right) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1637 (let ((sleft (car (cddr left))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1638 (sright (car (cddr right)))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1639 (if (string= sleft sright) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1640 (package-menu--name-predicate left right) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1641 (string< sleft sright)))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1642 |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1643 (defun package-menu--name-predicate (left right) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1644 (string< (symbol-name (caar left)) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1645 (symbol-name (caar right)))) |
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1646 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1647 (defun package-menu-sort-by-column (&optional e) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1648 "Sort the package menu by the column of the mouse click E." |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1649 (interactive "e") |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1650 (let* ((pos (event-start e)) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1651 (obj (posn-object pos)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1652 (col (if obj |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1653 (get-text-property (cdr obj) 'column-name (car obj)) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1654 (get-text-property (posn-point pos) 'column-name))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1655 (buf (window-buffer (posn-window (event-start e))))) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1656 (with-current-buffer buf |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1657 (when (eq major-mode 'package-menu-mode) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1658 (setq package-menu-sort-key col) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1659 (package--generate-package-list))))) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1660 |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1661 (defun package--list-packages (&optional packages) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1662 "Generate and pop to the *Packages* buffer. |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1663 Optional PACKAGES is a list of names of packages (symbols) to |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1664 list; the default is to display everything in `package-alist'." |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1665 (require 'finder-inf nil t) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1666 (with-current-buffer (get-buffer-create "*Packages*") |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1667 (package-menu-mode) |
110056
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1668 (set (make-local-variable 'package-menu-package-list) packages) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1669 (set (make-local-variable 'package-menu-sort-key) nil) |
8be2f62f7851
Fix several Package Menu and Finder bugs.
Chong Yidong <cyd@stupidchicken.com>
parents:
110017
diff
changeset
|
1670 (package--generate-package-list) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1671 ;; 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
|
1672 ;; 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
|
1673 ;; 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
|
1674 (pop-to-buffer (current-buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1675 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1676 ;;;###autoload |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1677 (defun list-packages () |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1678 "Display a list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1679 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
|
1680 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
|
1681 (interactive) |
111244
6a10cca95d2b
Check more carefully for packages before loading package.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
111142
diff
changeset
|
1682 ;; Initialize the package system if necessary. |
111327
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1683 (unless package--initialized |
27839df805b0
Separate built-in packages from elpa packages, for efficiency.
Chong Yidong <cyd@stupidchicken.com>
parents:
111318
diff
changeset
|
1684 (package-initialize t)) |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1685 (package-refresh-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1686 (package--list-packages)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1687 |
109970
77c4a65b9011
* emacs-lisp/package.el (list-packages): Alias for package-list-packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
109731
diff
changeset
|
1688 ;;;###autoload |
110017
10e66ac64b61
Merge Finder and package-menu functionality.
Chong Yidong <cyd@stupidchicken.com>
parents:
109992
diff
changeset
|
1689 (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
|
1690 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1691 (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
|
1692 "Display a list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1693 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
|
1694 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
|
1695 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1696 (package--list-packages)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1697 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1698 (provide 'package) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1699 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1700 ;;; package.el ends here |