Mercurial > emacs
annotate lisp/emacs-lisp/package.el @ 109016:d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Changes relative to version 0.9 of package.el are listed below:
* emacs-lisp/package-x.el: New file. Package uploading
functionality split out from package.el.
* emacs-lisp/package.el (package-archive-base): Point to
elpa.gnu.org.
(package-enable, package-load-list): New defcustoms.
(package-user-dir, package-directory-list): Turn into defcustoms.
Don't include package-user-dir in package-directory-list.
(package--builtins-base): Don't include Emacs as a "package".
(package-subdirectory-regexp): New var.
(package-load-all-descriptors, package-compute-transaction)
(package-download-transaction): Obey package-load-list.
(package-activate-1): Rename from package-do-activate.
(package-list-packages-internal): Check package-load-list.
(package-load-descriptor, package-generate-autoloads)
(package-unpack, package-unpack-single)
(package--read-archive-file, package-delete): Use
expand-file-name.
* startup.el (command-line): Load packages after reading init
file.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 16 Jun 2010 22:08:10 -0400 |
parents | |
children | 3fa4756bb7be |
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 ;; This code supports a single package repository, ELPA. All packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;; must be registered there. |
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 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
|
50 ;; 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
|
51 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; 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
|
53 ;; 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
|
54 ;; "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
|
55 ;; 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
|
56 ;; "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
|
57 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; A .el file will be named "NAME-VERSION.el" in ELPA, but will be |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; 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
|
60 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ;; The downloader will download all dependent packages. It will also |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 ;; byte-compile the package's lisp at install time. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 ;; 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
|
65 ;; 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
|
66 ;; 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
|
67 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 ;; 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
|
69 ;; |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ;; * 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
|
71 ;; * 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
|
72 ;; ~/.emacs.d/elpa/ directory. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 ;; * 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
|
74 ;; but we may change this. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 ;; * 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
|
76 ;; available to the user. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 ;; * 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
|
78 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 ;; 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
|
80 ;; |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 ;; M-x package-list-packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 ;; 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
|
83 ;; 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
|
84 ;; 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
|
85 ;; 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
|
86 ;; 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
|
87 ;; |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 ;; 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
|
89 ;; 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
|
90 ;; new list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 ;; |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 ;; 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
|
93 ;; 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
|
94 ;; 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
|
95 ;; 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
|
96 ;; 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
|
97 ;; 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
|
98 ;; packages). |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ;; |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 ;; M-x package-install-file |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 ;; 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
|
102 ;; 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
|
103 ;; 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
|
104 ;; 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
|
105 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 ;;; Thanks: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 ;;; (sorted by sort-lines): |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 ;; 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
|
110 ;; 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
|
111 ;; 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
|
112 ;; Lawrence Mitchell |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 ;; 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
|
114 ;; 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
|
115 ;; 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
|
116 ;; 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
|
117 ;; Phil Hagelberg <phil@hagelb.org> |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 ;;; ToDo: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 ;; - 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
|
122 ;; 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
|
123 ;; 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
|
124 ;; the standard layout? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 ;; - 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
|
126 ;; - 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
|
127 ;; 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
|
128 ;; - 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
|
129 ;; - 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
|
130 ;; only appears in the .el |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 ;; - 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
|
132 ;; - "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
|
133 ;; - 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
|
134 ;; 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
|
135 ;; - 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
|
136 ;; - 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
|
137 ;; 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
|
138 ;; 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
|
139 ;; - 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
|
140 ;; 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
|
141 ;; 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
|
142 ;; 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
|
143 ;; - 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
|
144 ;; installing it |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 ;; - 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
|
146 ;; works properly |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 ;; - 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
|
148 ;; - 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
|
149 ;; ... except maybe lisp? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 ;; - 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
|
151 ;; 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
|
152 ;; 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
|
153 ;; 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
|
154 ;; - package menu needs: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 ;; 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
|
156 ;; 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
|
157 ;; why is that? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 ;; - 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
|
159 ;; [ why bother? ] |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 ;; - 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
|
161 ;; - 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
|
162 ;; [ currently thinking, why bother.. KISS ] |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 ;; - Allow optional package dependencies |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 ;; 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
|
165 ;; 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
|
166 ;; - 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
|
167 ;; - 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
|
168 ;; 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
|
169 ;; 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
|
170 ;; 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
|
171 ;; tree layouts, build schemes, etc. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 ;; - 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
|
173 ;; - 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
|
174 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;;; Code: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 (defgroup package nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 "Manager for Emacs Lisp packages." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 :group 'applications |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 :version "24.1") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 (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
|
184 "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
|
185 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
|
186 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
|
187 `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
|
188 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 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
|
190 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
|
191 :type 'boolean |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 :group 'package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 :version "24.1") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (defcustom package-load-list '(all) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 "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
|
197 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
|
198 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
|
199 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
|
200 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 :type '(repeat symbol) |
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 (defvar gnus-article-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (declare-function info-initialize "info" ()) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (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
|
217 (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
|
218 (declare-function lm-commentary "lisp-mnt" (&optional file)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (declare-function dired-delete-file "dired" (file &optional recursive trash)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 (defconst package-archive-base "http://elpa.gnu.org/packages/" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 "Base URL for the Emacs Lisp Package Archive (ELPA). |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 Ordinarily you should not need to change this. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 Note that some code in package.el assumes that this is an http: URL.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 (defconst package-archive-version 1 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 "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
|
228 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
|
229 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (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
|
231 "Version of package.el.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 ;; 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
|
234 (defvar package-archive-contents nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 "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
|
236 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
|
237 descriptor vectors. These are like the vectors for `package-alist' |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 but have an extra entry which is 'tar for tar packages and |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 'single for single-file packages.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 (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
|
242 "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
|
243 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
|
244 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
|
245 packages in `package-directory-list'." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 :type 'directory |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 :group 'package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 :version "24.1") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (defcustom package-directory-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 ;; 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
|
252 (let (result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (dolist (f load-path) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (if (equal (file-name-nondirectory f) "site-lisp") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (push (expand-file-name "elpa" f) result))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 (nreverse result)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 "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
|
258 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
|
259 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 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
|
261 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
|
262 :type '(repeat directory) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 :group 'package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 :version "24.1") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (defun package-version-split (string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 "Split a package string into a version list." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 (mapcar 'string-to-int (split-string string "[.]"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 (defconst package--builtins-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 ;; We use package-version split here to make sure to pick up the |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 ;; minor version. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 `((emacs . [,(package-version-split emacs-version) nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 "GNU Emacs"]) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (package . [,(package-version-split package-el-version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 nil "Simple package system for GNU Emacs"])) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 "Packages which are always built-in.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 (defvar package--builtins |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (delq nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (append |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 package--builtins-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (if (>= emacs-major-version 22) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 ;; FIXME: emacs 22 includes tramp, rcirc, maybe |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 ;; other things... |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 '((erc . [(5 2) nil "An Emacs Internet Relay Chat client"]) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 ;; The external URL is version 1.15, so make sure the |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 ;; built-in one looks newer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 (url . [(1 16) nil "URL handling libary"]))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 (if (>= emacs-major-version 23) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 '(;; Strangely, nxml-version is missing in Emacs 23. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 ;; We pick the merge date as the version. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 (nxml . [(20071123) nil "Major mode for editing XML documents."]) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 (bubbles . [(0 5) nil "Puzzle game for Emacs."]))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 "Alist of all built-in packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 Maps the package name to a vector [VERSION REQS DOCSTRING].") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 (defvar package-alist package--builtins |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 "Alist of all packages available for activation. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 This maps the package name to a vector [VERSION REQS DOCSTRING]. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 The value is generated by `package-load-descriptor', usually |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 called via `package-initialize'. For user customizations of |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 which packages to load/activate, see `package-load-list'.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 (defvar package-activated-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (mapcar #'car package-alist) |
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.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (defvar package-obsolete-alist nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 "Representation of obsolete packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 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
|
313 The inner alist is keyed by version.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 (defconst package-subdirectory-regexp |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 "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
|
318 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
|
319 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
|
320 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (defun package-version-join (l) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 "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
|
323 (mapconcat 'int-to-string l ".")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 (defun package--version-first-nonzero (l) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (while (and l (= (car l) 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (setq l (cdr l))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (if l (car l) 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 (defun package-version-compare (v1 v2 fun) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 "Compare two version lists according to FUN. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 FUN can be <, <=, =, >, >=, or /=." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (while (and v1 v2 (= (car v1) (car v2))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 (setq v1 (cdr v1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 v2 (cdr v2))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (if v1 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 (if v2 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 ;; Both not null; we know the cars are not =. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 (funcall fun (car v1) (car v2)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ;; V1 not null, V2 null. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (funcall fun (package--version-first-nonzero v1) 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (if v2 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 ;; V1 null, V2 not null. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (funcall fun 0 (package--version-first-nonzero v2)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 ;; Both null. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 (funcall fun 0 0)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (defun package--test-version-compare () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 "Test suite for `package-version-compare'." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 (unless (and (package-version-compare '(0) '(0) '=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (not (package-version-compare '(1) '(0) '=)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (package-version-compare '(1 0 1) '(1) '>=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (package-version-compare '(1 0 1) '(1) '>) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (not (package-version-compare '(0 9 1) '(1 0 2) '>=))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (error "Failed")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (defun package-strip-version (dirname) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 "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
|
360 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
|
361 (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
|
362 (match-string 1 dirname))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (defun package-load-descriptor (dir package) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 "Load the description file for a package. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 DIR is the directory in which to find the package subdirectory, |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 and PACKAGE is the name of the package subdirectory. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 Return nil if the package could not be found." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 (let ((pkg-dir (expand-file-name package dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (if (file-directory-p pkg-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (load (expand-file-name (concat (package-strip-version package) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 "-pkg") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 pkg-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 nil t)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (defun package-load-all-descriptors () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 "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
|
378 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
|
379 `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
|
380 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
|
381 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 (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
|
386 name version force) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (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
|
388 (when (file-directory-p dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (dolist (subdir (directory-files dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (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
|
391 (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
|
392 (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
|
393 version (match-string 2 subdir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 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
|
395 (when (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 ((null force) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 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
|
398 ((null (setq force (cadr force))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 nil) ; disabled |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 ((eq force t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 ((stringp force) ; held |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (package-version-compare (package-version-split version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (package-version-split force) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 '=)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (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
|
408 (package-load-descriptor dir subdir)))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 (defsubst package-desc-vers (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 "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
|
412 (aref desc 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 (defsubst package-desc-reqs (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 "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
|
416 (aref desc 1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 (defsubst package-desc-doc (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 "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
|
420 (aref desc 2)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 (defsubst package-desc-kind (desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 "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
|
424 (aref desc 3)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 (defun package-activate-1 (package pkg-vec) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 (let* ((pkg-name (symbol-name package)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (pkg-ver-str (package-version-join (package-desc-vers pkg-vec))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 (dir-list (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
|
430 (pkg-dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 (while dir-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 (let ((subdir (expand-file-name (concat pkg-name "-" pkg-ver-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (car dir-list)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (if (file-directory-p subdir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 (setq pkg-dir subdir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 (setq dir-list nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 (setq dir-list (cdr dir-list))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 (unless pkg-dir |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 (error "Internal error: could not find directory for %s-%s" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 pkg-name pkg-ver-str)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (if (file-exists-p (expand-file-name "dir" pkg-dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 ;; FIXME: not the friendliest, but simple. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 (require 'info) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 (info-initialize) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 (setq Info-directory-list (cons pkg-dir Info-directory-list)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 (setq 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
|
449 ;; Load the autoloads and activate the package. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 (load (expand-file-name (concat (symbol-name package) "-autoloads") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 pkg-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 nil t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 (setq package-activated-list (cons package package-activated-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 ;; Don't return nil. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 t)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 (defun package--built-in (package version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 "Return true if the package is built-in to Emacs." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 (let ((elt (assq package package--builtins))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 (and elt |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (package-version-compare (package-desc-vers (cdr elt)) version '=)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 ;; FIXME: return a reason instead? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 (defun package-activate (package version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 "Activate a package, and recursively activate its dependencies. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 Return nil if the package could not be activated." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 ;; Assume the user knows what he is doing -- go ahead and activate a |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 ;; newer version of a package if an older one has already been |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 ;; activated. This is not ideal; we'd at least need to check to see |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 ;; if the package has actually been loaded, and not merely |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; activated. However, don't try to activate 'emacs', as that makes |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 ;; no sense. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 (unless (eq package 'emacs) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 (let* ((pkg-desc (assq package package-alist)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 (this-version (package-desc-vers (cdr pkg-desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 (req-list (package-desc-reqs (cdr pkg-desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 ;; If the package was never activated, we want to do it |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 ;; now. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 (keep-going (or (not (memq package package-activated-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 (package-version-compare this-version version '>)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 (while (and req-list keep-going) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 (let* ((req (car req-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 (req-name (car req)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 (req-version (cadr req))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 (or (package-activate req-name req-version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 (setq keep-going nil))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (setq req-list (cdr req-list))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (if keep-going |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 (package-activate-1 package (cdr pkg-desc)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 ;; We get here if a dependency failed to activate -- but we |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 ;; can also get here if the requested package was already |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 ;; activated. Return non-nil in the latter case. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 (and (memq package package-activated-list) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 (package-version-compare this-version version '>=)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 (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
|
497 "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
|
498 (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
|
499 (if elt |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 ;; 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
|
501 ;; it the list. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (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
|
503 (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
|
504 (cdr elt)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 ;; Make a new association. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 (setq package-obsolete-alist |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 (cons (cons package (list (cons (package-desc-vers pkg-vec) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 pkg-vec))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 package-obsolete-alist))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 ;; (define-package "emacs" "21.4.1" "GNU Emacs core package.") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 ;; (define-package "erc" "5.1" "ERC - irc client" '((emacs "21.0"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (defun define-package (name-str version-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 &optional docstring requirements) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 "Define a new package. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 NAME is the name of the package, a string. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 VERSION-STRING is the version of the package, a dotted sequence |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 of integers. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 DOCSTRING is the optional description. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 REQUIREMENTS is a list of requirements on other packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 Each requirement is of the form (OTHER-PACKAGE \"VERSION\")." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 (let* ((name (intern name-str)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 (pkg-desc (assq name package-alist)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (new-version (package-version-split version-string)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (new-pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 (cons name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 (vector new-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 (list (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 (package-version-split (car (cdr elt))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 requirements) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 docstring)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 ;; Only redefine a package if the redefinition is newer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 (if (or (not pkg-desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 (package-version-compare new-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 (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
|
538 '>)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 (when pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 ;; Remove old package and declare it obsolete. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 (setq package-alist (delq pkg-desc package-alist)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 (package-mark-obsolete (car pkg-desc) (cdr pkg-desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 ;; Add package to the alist. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 (setq package-alist (cons new-pkg-desc package-alist))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 ;; You can have two packages with the same version, for instance |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 ;; one in the system package directory and one in your private |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 ;; directory. We just let the first one win. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 (unless (package-version-compare new-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 (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
|
551 '=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 ;; The package is born obsolete. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 (package-mark-obsolete (car new-pkg-desc) (cdr new-pkg-desc)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 ;; From Emacs 22. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 (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
|
557 "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
|
558 (unless (file-exists-p file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 (write-region |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 (concat ";;; " (file-name-nondirectory file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 " --- automatically extracted autoloads\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 ";;\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 ";;; Code:\n\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 "\n;; Local Variables:\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 ";; version-control: never\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 ";; no-byte-compile: t\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 ";; no-update-autoloads: t\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 ";; End:\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 ";;; " (file-name-nondirectory file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 " ends here\n") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 nil file)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (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
|
575 (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
|
576 (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
|
577 (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
|
578 (version-control 'never)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 (require 'autoload) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 (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
|
581 (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
|
582 (update-directory-autoloads pkg-dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 (defun package-untar-buffer () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 "Untar the current buffer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 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
|
587 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
|
588 `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
|
589 (require 'tar-mode) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (if (fboundp 'tar-untar-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 ;; 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
|
593 ;; whole buffer to play with. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 (delete-region (point-min) (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 (tar-mode) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 (tar-untar-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 ;; FIXME: check the result. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 (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
|
599 "xf" "-"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 (defun package-unpack (name version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (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
|
603 package-user-dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 ;; Be careful!! |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 (make-directory package-user-dir t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 (if (file-directory-p pkg-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 (mapc (lambda (file) nil) ; 'delete-file -- FIXME: when we're |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 ; more confident |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 (directory-files pkg-dir t "^[^.]"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 (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
|
611 (package-untar-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 (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
|
613 (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
|
614 (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
|
615 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (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
|
617 "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
|
618 ;; Special case "package". |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (if (string= file-name "package") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 (write-region (point-min) (point-max) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (expand-file-name (concat file-name ".el") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 package-user-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 nil nil nil nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (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
|
625 package-user-dir)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 (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
|
627 (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
|
628 (make-directory pkg-dir t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (write-region (point-min) (point-max) el-file nil nil nil 'excl) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (let ((print-level nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 (print-length nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (write-region |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 (concat |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (prin1-to-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (list 'define-package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 file-name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (list 'quote |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 ;; 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
|
641 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 (list (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 (package-version-join (car (cdr elt))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 requires)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 "\n") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 pkg-file |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 nil nil nil 'excl)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (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
|
651 (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
|
652 (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
|
653 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 (defun package-handle-response () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 "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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 ;; We assume HTTP here. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (require 'url-http) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (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
|
663 (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
|
664 (display-buffer (current-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (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
|
666 (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
|
667 (end-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (point))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 (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
|
671 "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
|
672 (let ((buffer (url-retrieve-synchronously |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 (concat package-archive-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 (symbol-name name) "-" version ".el")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (with-current-buffer buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 (delete-region (point-min) (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 (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
|
681 (kill-buffer buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 (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
|
684 "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
|
685 (let ((tar-buffer (url-retrieve-synchronously |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (concat package-archive-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (symbol-name name) "-" version ".tar")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (with-current-buffer tar-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 (package-unpack name version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 (kill-buffer tar-buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (defun package-installed-p (package version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (let ((pkg-desc (assq package package-alist))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (and pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (package-version-compare version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (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
|
700 '>=)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (defun package-compute-transaction (result requirements) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (dolist (elt requirements) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 (let* ((next-pkg (car elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 (next-version (cadr elt))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 (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
|
707 ;; 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
|
708 ;; blocked via `package-load-list'. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 (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
|
710 hold) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 (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
|
712 (setq hold (cadr hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (cond ((eq hold nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (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
|
715 (symbol-name next-pkg))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 ((null (stringp hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 (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
|
718 ((package-version-compare next-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (package-version-split hold) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 '>) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 (error "Package '%s' held at version %s, \ |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 but version %s required" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (symbol-name next-pkg) hold |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (package-version-join next-version))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 (unless pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 (error "Package '%s' is not available for installation" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 (symbol-name next-pkg))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 (unless (package-version-compare (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
|
729 next-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 '>=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 (error |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 "Need package '%s' with version %s, but only %s is available" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 (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
|
734 (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
|
735 ;; Only add to the transaction if we don't already have it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (unless (memq next-pkg result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 (setq result (cons next-pkg result))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 (setq result |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 (package-compute-transaction result |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (package-desc-reqs |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 (cdr pkg-desc)))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 (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
|
745 "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
|
746 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
|
747 (let* ((read-data (read-from-string str)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 (more-left |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 (condition-case nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 ;; The call to `ignore' suppresses a compiler warning. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 (progn (ignore (read-from-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 (substring str (cdr read-data)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (end-of-file nil)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (if more-left |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 (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
|
757 (car read-data)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 (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
|
760 "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
|
761 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
|
762 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
|
763 (let ((filename (expand-file-name file package-user-dir))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 (if (file-exists-p filename) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 (with-temp-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 (insert-file-contents-literally filename) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (let ((contents (package-read-from-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 (buffer-substring-no-properties (point-min) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (point-max))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (if (> (car contents) package-archive-version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (error "Package archive version %d is greater than %d - upgrade package.el" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (car contents) package-archive-version)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 (cdr contents)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 (defun package-read-archive-contents () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 "Re-read `archive-contents' and `builtin-packages', if they exist. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 Set `package-archive-contents' and `package--builtins' if successful. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 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
|
779 (let ((archive-contents (package--read-archive-file "archive-contents")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (builtins (package--read-archive-file "builtin-packages"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (if archive-contents |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 ;; Version 1 of 'archive-contents' is identical to our |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 ;; internal representation. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 (setq package-archive-contents archive-contents)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 (if builtins |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 ;; Version 1 of 'builtin-packages' is a list where the car is |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 ;; a split emacs version and the cdr is an alist suitable for |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 ;; package--builtins. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 (let ((our-version (package-version-split emacs-version)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (result package--builtins-base)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 (setq package--builtins |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (dolist (elt builtins result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 (if (package-version-compare our-version (car elt) '>=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 (setq result (append (cdr elt) result))))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (defun package-download-transaction (transaction) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 "Download and install all the packages in the given transaction." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (dolist (elt transaction) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (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
|
800 ;; 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
|
801 ;; `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
|
802 (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
|
803 (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
|
804 (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
|
805 (kind (package-desc-kind desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 ((eq kind 'tar) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 (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
|
809 ((eq kind 'single) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 (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
|
811 (package-desc-doc desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 (package-desc-reqs desc))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (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
|
815 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 (defun package-install (name) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 "Install the package named NAME. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 Interactively, prompt for the package name. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 The package is found on the archive site, see `package-archive-base'." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (interactive |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 (list (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 ;; Make sure we're using the most recent download of the |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 ;; archive. Maybe we should be updating the archive first? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 (package-read-archive-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 (intern (completing-read "Install package: " |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 (mapcar (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 (cons (symbol-name (car elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 package-archive-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 nil t))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 (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
|
833 (unless pkg-desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 (error "Package '%s' not available for installation" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 (symbol-name name))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (let ((transaction |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (package-compute-transaction (list name) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 (package-desc-reqs (cdr pkg-desc))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 (package-download-transaction transaction))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 ;; Try to activate it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 (package-initialize)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 (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
|
844 "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
|
845 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
|
846 Otherwise return nil." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 (if v-str |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 (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
|
849 (match-string 1 v-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 (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
|
851 v-str)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 (defun package-buffer-info () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 "Return a vector of information about the package in the current buffer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
855 The vector looks like [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY] |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 FILENAME is the file name, a string. It does not have the \".el\" extension. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 REQUIRES is a requires list, or nil. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 DESCRIPTION is the package description (a string). |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 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
|
860 COMMENTARY is the commentary section, a string, or nil if none. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 Throws an exception if the buffer does not contain a conforming package. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 If there is a package, narrows the buffer to the file's boundaries. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 May narrow buffer or move point even on failure." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 (if (re-search-forward "^;;; \\([^ ]*\\)\\.el --- \\(.*\\)$" nil t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 (let ((file-name (match-string 1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
867 (desc (match-string 2)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
868 (start (progn (beginning-of-line) (point)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 (if (search-forward (concat ";;; " file-name ".el ends here")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 (progn |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 ;; Try to include a trailing newline. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 (forward-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 (narrow-to-region start (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 (require 'lisp-mnt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 ;; Use some headers we've invented to drive the process. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 (let* ((requires-str (lm-header "package-requires")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 (requires (if requires-str |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
878 (package-read-from-string requires-str))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
879 ;; Prefer Package-Version, because if it is |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 ;; defined the package author probably wants us |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 ;; to use it. Otherwise try Version. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 (pkg-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 (or (package-strip-rcs-id (lm-header "package-version")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (package-strip-rcs-id (lm-header "version")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 (commentary (lm-commentary))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 (unless pkg-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 (error |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 "Package does not define a usable \"Version\" or \"Package-Version\" header")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 ;; 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
|
890 (setq requires |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 (list (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 (package-version-split (car (cdr elt))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 requires)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 (set-text-properties 0 (length file-name) nil file-name) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
897 (set-text-properties 0 (length pkg-version) nil pkg-version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 (set-text-properties 0 (length desc) nil desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 (vector file-name requires desc pkg-version commentary))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 (error "Package missing a terminating comment"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 (error "No starting comment for package"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 (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
|
904 "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
|
905 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
|
906 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
|
907 (unless (string-match "^\\(.+\\)-\\([0-9.]+\\)\\.tar$" file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 (error "`%s' doesn't have a package-ish name" file)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 (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
|
910 (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
|
911 ;; Extract the package descriptor. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 (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
|
913 ;; Requires GNU tar. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 (concat "tar -xOf " file " " |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 pkg-name "-" pkg-version "/" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 pkg-name "-pkg.el"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 (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
|
918 (unless (eq (car pkg-def-parsed) 'define-package) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 (error "%s-pkg.el doesn't contain `define-package' sexp" pkg-name)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 (let ((name-str (nth 1 pkg-def-parsed)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 (version-string (nth 2 pkg-def-parsed)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 (docstring (nth 3 pkg-def-parsed)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 (requires (nth 4 pkg-def-parsed)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 (readme (shell-command-to-string |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 ;; Requires GNU tar. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 (concat "tar -xOf " file " " |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 pkg-name "-" pkg-version "/README")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 (unless (equal pkg-version version-string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (error "Inconsistent versions!")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 (unless (equal pkg-name name-str) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 (error "Inconsistent names!")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 ;; Kind of a hack. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 (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
|
935 (setq readme nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 ;; 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
|
937 (if (eq (car requires) 'quote) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 (setq requires (car (cdr requires)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 (setq requires |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 (mapcar |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 (list (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (package-version-split (car (cdr elt))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 requires)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 (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
|
946 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 (defun package-install-buffer-internal (pkg-info type) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 (save-restriction |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 (let* ((file-name (aref pkg-info 0)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 (requires (aref pkg-info 1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 (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
|
953 "No description available." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 (aref pkg-info 2))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 (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
|
956 ;; Download and install the dependencies. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 (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
|
958 (package-download-transaction transaction)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 ;; Install the package itself. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
960 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 ((eq type 'single) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
962 (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
|
963 ((eq type 'tar) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 (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
|
965 (t |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (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
|
967 ;; Try to activate it. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 (package-initialize))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 (defun package-install-from-buffer () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 "Install a package from the current buffer. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 The package is assumed to be a single .el file which |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 follows the elisp comment guidelines; see |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 info node `(elisp)Library Headers'." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 (package-install-buffer-internal (package-buffer-info) 'single)) |
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 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 (defun package-install-file (file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 "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
|
982 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
|
983 (interactive "fPackage file name: ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 (with-temp-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
985 (insert-file-contents-literally file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 ((string-match "\\.el$" file) (package-install-from-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 ((string-match "\\.tar$" file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 (package-install-buffer-internal (package-tar-file-info file) 'tar)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 (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
|
991 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
992 (defun package-delete (name version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 (require 'dired) ; for dired-delete-file |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 (dired-delete-file (expand-file-name (concat name "-" version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
995 package-user-dir) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
996 ;; FIXME: query user? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
997 'always)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
998 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 (defun package--download-one-archive (file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 "Download a single archive file and cache it locally." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1001 (let ((buffer (url-retrieve-synchronously |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1002 (concat package-archive-base file)))) |
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)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 (setq buffer-file-name (concat (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
|
1009 file)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 (let ((version-control 'never)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1011 (save-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 (kill-buffer buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1014 (defun package-refresh-contents () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1015 "Download the ELPA archive description if needed. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1016 Invoking this will ensure that Emacs knows about the latest versions |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1017 of all packages. This will let Emacs make them available for |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1018 download." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1019 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1020 (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
|
1021 (make-directory package-user-dir t)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1022 (package--download-one-archive "archive-contents") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1023 (package--download-one-archive "builtin-packages") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1024 (package-read-archive-contents)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1025 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1026 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1027 (defun package-initialize () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1028 "Load Emacs Lisp packages, and activate them. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 The variable `package-load-list' controls which packages to load." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 (setq package-obsolete-alist nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 (package-load-all-descriptors) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 (package-read-archive-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 ;; Try to activate all our packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 (mapc (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1036 (package-activate (car elt) (package-desc-vers (cdr elt)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1037 package-alist)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 ;;;; Package menu mode. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1043 (defvar package-menu-mode-map nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 "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
|
1045 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1046 (unless package-menu-mode-map |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 (setq package-menu-mode-map (make-keymap)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 (suppress-keymap package-menu-mode-map) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 (define-key package-menu-mode-map "q" 'quit-window) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 (define-key package-menu-mode-map "n" 'next-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1051 (define-key package-menu-mode-map "p" 'previous-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1052 (define-key package-menu-mode-map "u" 'package-menu-mark-unmark) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1053 (define-key package-menu-mode-map "\177" 'package-menu-backup-unmark) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1054 (define-key package-menu-mode-map "d" 'package-menu-mark-delete) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1055 (define-key package-menu-mode-map "i" 'package-menu-mark-install) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 (define-key package-menu-mode-map "g" 'package-menu-revert) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1057 (define-key package-menu-mode-map "r" 'package-menu-refresh) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1058 (define-key package-menu-mode-map "~" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 '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
|
1060 (define-key package-menu-mode-map "x" 'package-menu-execute) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 (define-key package-menu-mode-map "h" 'package-menu-quick-help) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 (define-key package-menu-mode-map "?" 'package-menu-view-commentary)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 (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
|
1065 (let ((map (make-sparse-keymap))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 (define-key map [header-line mouse-1] 'package-menu-sort-by-column) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 (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
|
1068 map) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1069 "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
|
1070 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 (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
|
1072 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 (defun package-menu-mode () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 "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
|
1075 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
|
1076 \\<package-menu-mode-map> |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 \\{package-menu-mode-map}" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 (kill-all-local-variables) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 (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
|
1080 (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
|
1081 (setq mode-name "Package Menu") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 (setq truncate-lines t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 (setq buffer-read-only t) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 ;; Support Emacs 21. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 (if (fboundp 'run-mode-hooks) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 (run-mode-hooks 'package-menu-mode-hook) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 (run-hooks 'package-menu-mode-hook))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1088 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 (defun package-menu-refresh () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1090 "Download the ELPA archive. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 This fetches the file describing the current contents of |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1092 the Emacs Lisp Package Archive, and then refreshes the |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1093 package menu. This lets you see what new packages are |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 available for download." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1095 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1096 (package-refresh-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 (package-list-packages-internal)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 (defun package-menu-revert () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 "Update the list of packages." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 (package-list-packages-internal)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 (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
|
1105 (unless (eobp) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 (let ((buffer-read-only nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 (delete-char 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 (insert what) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 (forward-line)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1111 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 ;; fixme numeric argument |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 (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
|
1114 "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
|
1115 (interactive "p") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 (package-menu-mark-internal "D")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 (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
|
1119 "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
|
1120 (interactive "p") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 (package-menu-mark-internal "I")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1123 (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
|
1124 "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
|
1125 (interactive "p") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 (package-menu-mark-internal " ")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 (defun package-menu-backup-unmark () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 "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
|
1130 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1131 (forward-line -1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1132 (package-menu-mark-internal " ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 (forward-line -1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 (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
|
1136 "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
|
1137 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 (forward-line 2) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 (while (not (eobp)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 (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
|
1143 (package-menu-mark-internal "D") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 (forward-line 1))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1146 (defun package-menu-quick-help () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1147 "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
|
1148 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 (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
|
1150 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 (defun package-menu-view-commentary () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 "Display information about this package. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 For single-file packages, shows the commentary section from the header. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 For larger packages, shows the README file." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 (let* (start-point ok |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1157 (pkg-name (package-menu-get-package)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1158 (buffer (url-retrieve-synchronously (concat package-archive-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 pkg-name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 "-readme.txt")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 (with-current-buffer buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1162 ;; FIXME: it would be nice to work with any URL type. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1163 (setq start-point url-http-end-of-headers) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 (setq ok (eq (url-http-parse-response) 200))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 (let ((new-buffer (get-buffer-create "*Package Info*"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 (with-current-buffer new-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 (let ((buffer-read-only nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 (erase-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 (insert "Package information for " pkg-name "\n\n") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 (if ok |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 (insert-buffer-substring buffer start-point) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 (insert "This package does not have a README file or commentary comment.\n")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1174 (view-mode))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1175 (display-buffer new-buffer t)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 ;; 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
|
1178 (defun package-menu-get-package () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1180 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1181 (if (looking-at ". \\([^ \t]*\\)") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 (match-string 1)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 ;; 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
|
1185 (defun package-menu-get-version () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 (beginning-of-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1188 (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
|
1189 (match-string 1)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 (defun package-menu-get-status () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1192 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 (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
|
1194 (match-string 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 ""))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 (defun package-menu-execute () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1198 "Perform all the marked actions. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1199 Packages marked for installation will be downloaded and |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1200 installed. Packages marked for deletion will be removed. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1201 Note that after installing packages you will want to restart |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1202 Emacs." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1203 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1204 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1205 (forward-line 2) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1206 (while (not (eobp)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1207 (let ((cmd (char-after)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1208 (pkg-name (package-menu-get-package)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1209 (pkg-vers (package-menu-get-version)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1210 (pkg-status (package-menu-get-status))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1211 (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1212 ((eq cmd ?D) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1213 (when (and (string= pkg-status "installed") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1214 (string= pkg-name "package")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1215 ;; FIXME: actually, we could be tricky and remove all info. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1216 ;; But that is drastic and the user can do that instead. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1217 (error "Can't delete most recent version of `package'")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1218 ;; Ask for confirmation here? Maybe if package status is ""? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1219 ;; Or if any lisp from package is actually loaded? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1220 (message "Deleting %s-%s..." pkg-name pkg-vers) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1221 (package-delete pkg-name pkg-vers) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1222 (message "Deleting %s-%s... done" pkg-name pkg-vers)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1223 ((eq cmd ?I) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1224 (package-install (intern pkg-name))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1225 (forward-line)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1226 (package-menu-revert)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1227 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1228 (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
|
1229 (let ((face |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1230 (cond ((eq package 'emacs) 'font-lock-builtin-face) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1231 ((string= key "available") 'default) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1232 ((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
|
1233 ((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
|
1234 ((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
|
1235 (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
|
1236 'font-lock-warning-face)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1237 (insert (propertize " " 'font-lock-face face)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1238 (insert (propertize (symbol-name package) 'font-lock-face face)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1239 (indent-to 20 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1240 (insert (propertize (package-version-join version) 'font-lock-face face)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1241 (indent-to 30 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1242 (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
|
1243 ;; FIXME: this 'when' is bogus... |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1244 (when desc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1245 (indent-to 41 1) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1246 (insert (propertize desc 'font-lock-face face))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1247 (insert "\n"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1248 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1249 (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
|
1250 (unless (assoc (cons package version) result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1251 (setq result (cons (list (cons package version) status description) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1252 result))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1253 result) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1254 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1255 ;; This decides how we should sort; nil means by package name. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1256 (defvar package-menu-sort-key nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1257 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1258 (defun package-list-packages-internal () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1259 (package-initialize) ; FIXME: do this here? |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1260 (with-current-buffer (get-buffer-create "*Packages*") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1261 (setq buffer-read-only nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1262 (erase-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1263 (let ((info-list) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1264 name desc hold) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1265 ;; List installed packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1266 (dolist (elt package-alist) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1267 (setq name (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1268 desc (cdr elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1269 hold (assq name package-load-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1270 (setq info-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1271 (package-list-maybe-add name (package-desc-vers desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1272 ;; FIXME: it turns out to be |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1273 ;; tricky to see if this package |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1274 ;; is presently activated. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1275 (if (stringp (cadr hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1276 "held" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1277 "installed") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1278 (package-desc-doc desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1279 info-list))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1280 ;; List available packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1281 (dolist (elt package-archive-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1282 (setq name (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1283 desc (cdr elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1284 hold (assq name package-load-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1285 (unless (and hold (stringp (cadr hold)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1286 (package-installed-p |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1287 name (package-version-split (cadr hold)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1288 (setq info-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1289 (package-list-maybe-add name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1290 (package-desc-vers desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1291 (if (and hold (null (cadr hold))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1292 "disabled" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1293 "available") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1294 (package-desc-doc (cdr elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1295 info-list)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1296 ;; List obsolete packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1297 (mapc (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1298 (mapc (lambda (inner-elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1299 (setq info-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1300 (package-list-maybe-add (car elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1301 (package-desc-vers |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1302 (cdr inner-elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1303 "obsolete" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1304 (package-desc-doc |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1305 (cdr inner-elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1306 info-list))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1307 (cdr elt))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1308 package-obsolete-alist) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1309 (let ((selector (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1310 ((string= package-menu-sort-key "Version") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1311 ;; FIXME this doesn't work. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1312 #'(lambda (e) (cdr (car e)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1313 ((string= package-menu-sort-key "Status") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1314 #'(lambda (e) (car (cdr e)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1315 ((string= package-menu-sort-key "Description") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1316 #'(lambda (e) (car (cdr (cdr e))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1317 (t ; "Package" is default. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1318 #'(lambda (e) (symbol-name (car (car e)))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1319 (setq info-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1320 (sort info-list |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1321 (lambda (left right) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1322 (let ((vleft (funcall selector left)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1323 (vright (funcall selector right))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1324 (string< vleft vright)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1325 (mapc (lambda (elt) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1326 (package-print-package (car (car elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1327 (cdr (car elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1328 (car (cdr elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1329 (car (cdr (cdr elt))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1330 info-list)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1331 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1332 (current-buffer))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1333 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1334 (defun package-menu-sort-by-column (&optional e) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1335 "Sort the package menu by the last column clicked on." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1336 (interactive (list last-input-event)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1337 (if e (mouse-select-window e)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1338 (let* ((pos (event-start e)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1339 (obj (posn-object pos)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1340 (col (if obj |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1341 (get-text-property (cdr obj) 'column-name (car obj)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1342 (get-text-property (posn-point pos) 'column-name)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1343 (setq package-menu-sort-key col)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1344 (package-list-packages-internal)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1345 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1346 (defun package--list-packages () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1347 "Display a list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1348 Helper function that does all the work for the user-facing functions." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1349 (with-current-buffer (package-list-packages-internal) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1350 (package-menu-mode) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1351 ;; Set up the header line. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1352 (setq header-line-format |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1353 (mapconcat |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1354 (lambda (pair) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1355 (let ((column (car pair)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1356 (name (cdr pair))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1357 (concat |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1358 ;; Insert a space that aligns the button properly. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1359 (propertize " " 'display (list 'space :align-to column) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1360 'face 'fixed-pitch) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1361 ;; Set up the column button. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1362 (if (string= name "Version") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1363 name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1364 (propertize name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1365 'column-name name |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1366 'help-echo "mouse-1: sort by column" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1367 'mouse-face 'highlight |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1368 'keymap package-menu-sort-button-map))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1369 ;; We take a trick from buff-menu and have a dummy leading |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1370 ;; space to align the header line with the beginning of the |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1371 ;; text. This doesn't really work properly on Emacs 21, |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1372 ;; but it is close enough. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1373 '((0 . "") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1374 (2 . "Package") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1375 (20 . "Version") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1376 (30 . "Status") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1377 (41 . "Description")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1378 "")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1379 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1380 ;; It's okay to use pop-to-buffer here. The package menu buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1381 ;; has keybindings, and the user just typed 'M-x |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1382 ;; package-list-packages', suggesting that they might want to use |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1383 ;; them. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1384 (pop-to-buffer (current-buffer)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1385 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1386 ;;;###autoload |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1387 (defun package-list-packages () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1388 "Display a list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1389 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
|
1390 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
|
1391 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1392 (package-refresh-contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1393 (package--list-packages)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1394 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1395 (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
|
1396 "Display a list of packages. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1397 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
|
1398 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
|
1399 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1400 (package--list-packages)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1401 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1402 ;; Make it appear on the menu. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1403 (define-key-after menu-bar-options-menu [package] |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1404 '(menu-item "Manage Packages" package-list-packages |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1405 :help "Install or uninstall additional Emacs packages")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1406 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1407 (provide 'package) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1408 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1409 ;;; package.el ends here |