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