Mercurial > dotfiles
annotate .elisp/old/package.el @ 455:b60cd2f46acd
emacs: add rainbow-delimiters
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 06 Jan 2018 20:46:20 -0500 |
parents | ea73ef5dc38c |
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 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
3 ;; Copyright (C) 2007-2011 Free Software Foundation, Inc. |
211
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 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
7 ;; Version: 0.9 |
211
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 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 ;; 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
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 ;; 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
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 ;; 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
|
23 ;; 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
|
24 ;; 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
|
25 ;; 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
|
26 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
27 ;;; Change Log: |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
29 ;; 2 Apr 2007 - now using ChangeLog file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
30 ;; 15 Mar 2007 - updated documentation |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
31 ;; 14 Mar 2007 - Changed how obsolete packages are handled |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
32 ;; 13 Mar 2007 - Wrote package-install-from-buffer |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
33 ;; 12 Mar 2007 - Wrote package-menu mode |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
35 ;;; Commentary: |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 ;; 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
|
38 ;; 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
|
39 ;; 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
|
40 ;; 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
|
41 ;; 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
|
42 ;; 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
|
43 ;; 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
|
44 ;; work.) |
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 ;; 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
|
47 ;; 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
|
48 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 ;; 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
|
50 ;; 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
|
51 ;; "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
|
52 ;; 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
|
53 ;; "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
|
54 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
55 ;; A .el file is named "NAME-VERSION.el" in the remote archive, but is |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 ;; 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
|
57 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
58 ;; The downloader downloads all dependent packages. By default, |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
59 ;; packages come from the official GNU sources, but others may be |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
60 ;; added by customizing the `package-archives' alist. Packages get |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
61 ;; byte-compiled at install time. |
211
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 ;; 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
|
64 ;; 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
|
65 ;; 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
|
66 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 ;; 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
|
68 ;; |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 ;; * 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
|
70 ;; * 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
|
71 ;; ~/.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
|
72 ;; * 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
|
73 ;; 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
|
74 ;; * 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
|
75 ;; 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
|
76 ;; * 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
|
77 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
78 ;; Other external functions you may want to use: |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
79 ;; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
80 ;; M-x list-packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
81 ;; Enters a mode similar to buffer-menu which lets you manage |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
82 ;; packages. You can choose packages for install (mark with "i", |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
83 ;; then "x" to execute) or deletion (not implemented yet), and you |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
84 ;; can see what packages are available. This will automatically |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
85 ;; fetch the latest list of packages from ELPA. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
86 ;; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
87 ;; M-x package-list-packages-no-fetch |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
88 ;; Like package-list-packages, but does not automatically fetch the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
89 ;; new list of packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
90 ;; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
91 ;; M-x package-install-from-buffer |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
92 ;; Install a package consisting of a single .el file that appears |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
93 ;; in the current buffer. This only works for packages which |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
94 ;; define a Version header properly; package.el also supports the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
95 ;; extension headers Package-Version (in case Version is an RCS id |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
96 ;; or similar), and Package-Requires (if the package requires other |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
97 ;; packages). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
98 ;; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
99 ;; M-x package-install-file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
100 ;; Install a package from the indicated file. The package can be |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
101 ;; either a tar file or a .el file. A tar file must contain an |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
102 ;; appropriately-named "-pkg.el" file; a .el file must be properly |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
103 ;; formatted as with package-install-from-buffer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
104 |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 ;;; Thanks: |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 ;;; (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
|
107 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 ;; 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
|
109 ;; 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
|
110 ;; 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
|
111 ;; Lawrence Mitchell |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 ;; 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
|
113 ;; 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
|
114 ;; 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
|
115 ;; 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
|
116 ;; 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
|
117 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
118 ;;; ToDo: |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
119 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
120 ;; - putting info dirs at the start of the info path means |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
121 ;; users see a weird ordering of categories. OTOH we want to |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
122 ;; override later entries. maybe emacs needs to enforce |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
123 ;; the standard layout? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
124 ;; - put bytecode in a separate directory tree |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
125 ;; - perhaps give users a way to recompile their bytecode |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
126 ;; or do it automatically when emacs changes |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
127 ;; - give users a way to know whether a package is installed ok |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
128 ;; - give users a way to view a package's documentation when it |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
129 ;; only appears in the .el |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
130 ;; - use/extend checkdoc so people can tell if their package will work |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
131 ;; - "installed" instead of a blank in the status column |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
132 ;; - tramp needs its files to be compiled in a certain order. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
133 ;; how to handle this? fix tramp? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
134 ;; - on emacs 21 we don't kill the -autoloads.el buffer. what about 22? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
135 ;; - maybe we need separate .elc directories for various emacs versions |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
136 ;; and also emacs-vs-xemacs. That way conditional compilation can |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
137 ;; work. But would this break anything? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
138 ;; - should store the package's keywords in archive-contents, then |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
139 ;; let the users filter the package-menu by keyword. See |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
140 ;; finder-by-keyword. (We could also let people view the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
141 ;; Commentary, but it isn't clear how useful this is.) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
142 ;; - William Xu suggests being able to open a package file without |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
143 ;; installing it |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
144 ;; - Interface with desktop.el so that restarting after an install |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
145 ;; works properly |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
146 ;; - Implement M-x package-upgrade, to upgrade any/all existing packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
147 ;; - Use hierarchical layout. PKG/etc PKG/lisp PKG/info |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
148 ;; ... except maybe lisp? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
149 ;; - It may be nice to have a macro that expands to the package's |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
150 ;; private data dir, aka ".../etc". Or, maybe data-directory |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
151 ;; needs to be a list (though this would be less nice) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
152 ;; a few packages want this, eg sokoban |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
153 ;; - package menu needs: |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
154 ;; ability to know which packages are built-in & thus not deletable |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
155 ;; it can sometimes print odd results, like 0.3 available but 0.4 active |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
156 ;; why is that? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
157 ;; - Allow multiple versions on the server...? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
158 ;; [ why bother? ] |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
159 ;; - Don't install a package which will invalidate dependencies overall |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
160 ;; - Allow something like (or (>= emacs 21.0) (>= xemacs 21.5)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
161 ;; [ currently thinking, why bother.. KISS ] |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
162 ;; - Allow optional package dependencies |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
163 ;; then if we require 'bbdb', bbdb-specific lisp in lisp/bbdb |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
164 ;; and just don't compile to add to load path ...? |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
165 ;; - Have a list of archive URLs? [ maybe there's no point ] |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
166 ;; - David Kastrup pointed out on the xemacs list that for GPL it |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
167 ;; is friendlier to ship the source tree. We could "support" that |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
168 ;; by just having a "src" subdir in the package. This isn't ideal |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
169 ;; but it probably is not worth trying to support random source |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
170 ;; tree layouts, build schemes, etc. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
171 ;; - Our treatment of the info path is somewhat bogus |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
172 ;; - perhaps have an "unstable" tree in ELPA as well as a stable one |
211
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 ;;; Code: |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
175 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
176 (defgroup package nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
177 "Manager for Emacs Lisp packages." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
178 :group 'applications |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
179 :version "24.1") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
180 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
181 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
182 (defcustom package-enable-at-startup t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
183 "Whether to activate installed packages when Emacs starts. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
184 If non-nil, packages are activated after reading the init file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
185 and before `after-init-hook'. Activation is not done if |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
186 `user-init-file' is nil (e.g. Emacs was started with \"-q\"). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
187 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
188 Even if the value is nil, you can type \\[package-initialize] to |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
189 activate the package system at any time." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
190 :type 'boolean |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
191 :group 'package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
192 :version "24.1") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
193 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
194 (defcustom package-load-list '(all) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
195 "List of packages for `package-initialize' to load. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
196 Each element in this list should be a list (NAME VERSION), or the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
197 symbol `all'. The symbol `all' says to load the latest installed |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
198 versions of all packages not specified by other elements. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
199 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
200 For an element (NAME VERSION), NAME is a package name (a symbol). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
201 VERSION should be t, a string, or nil. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
202 If VERSION is t, all versions are loaded, though obsolete ones |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
203 will be put in `package-obsolete-alist' and not activated. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
204 If VERSION is a string, only that version is ever loaded. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
205 Any other version, even if newer, is silently ignored. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
206 Hence, the package is \"held\" at that version. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
207 If VERSION is nil, the package is not loaded (it is \"disabled\")." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
208 :type '(repeat symbol) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
209 :risky t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
210 :group 'package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
211 :version "24.1") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
212 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
213 (defvar Info-directory-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
214 (declare-function info-initialize "info" ()) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
215 (declare-function url-http-parse-response "url-http" ()) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
216 (declare-function lm-header "lisp-mnt" (header)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
217 (declare-function lm-commentary "lisp-mnt" (&optional file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
218 (defvar url-http-end-of-headers) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
219 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
220 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
221 "An alist of archives from which to fetch. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
222 The default value points to the GNU Emacs package repository. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
223 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
224 Each element has the form (ID . LOCATION). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
225 ID is an archive name, as a string. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
226 LOCATION specifies the base location for the archive. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
227 If it starts with \"http:\", it is treated as a HTTP URL; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
228 otherwise it should be an absolute directory name. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
229 (Other types of URL are currently not supported.)" |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 :type '(alist :key-type (string :tag "Archive name") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
231 :value-type (string :tag "URL or directory name")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
232 :risky t |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
233 :group 'package |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
234 :version "24.1") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 (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
|
237 "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
|
238 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
|
239 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
240 (defconst package-el-version "1.0" |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 "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
|
242 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 ;; We don't prime the cache since it tends to get out of date. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
244 (defvar package-archive-contents nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
245 "Cache of the contents of the Emacs Lisp Package Archive. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 '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
|
250 the archive from which it came.") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
251 (put 'package-archive-contents 'risky-local-variable t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
252 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
253 (defcustom package-user-dir (locate-user-emacs-file "elpa") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
254 "Directory containing the user's Emacs Lisp packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
255 The directory name should be absolute. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
256 Apart from this directory, Emacs also looks for system-wide |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
257 packages in `package-directory-list'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
258 :type 'directory |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
259 :risky t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
260 :group 'package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
261 :version "24.1") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
262 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
263 (defcustom package-directory-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
264 ;; Defaults are subdirs named "elpa" in the site-lisp dirs. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
265 (let (result) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
266 (dolist (f load-path) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
267 (and (stringp f) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
268 (equal (file-name-nondirectory f) "site-lisp") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
269 (push (expand-file-name "elpa" f) result))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
270 (nreverse result)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
271 "List of additional directories containing Emacs Lisp packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
272 Each directory name should be absolute. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
273 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
274 These directories contain packages intended for system-wide; in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
275 contrast, `package-user-dir' contains packages for personal use." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
276 :type '(repeat directory) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
277 :risky t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
278 :group 'package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
279 :version "24.1") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
280 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
281 ;; The value is precomputed in finder-inf.el, but don't load that |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
282 ;; until it's needed (i.e. when `package-intialize' is called). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
283 (defvar package--builtins nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
284 "Alist of built-in packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
285 The actual value is initialized by loading the library |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
286 `finder-inf'; this is not done until it is needed, e.g. by the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
287 function `package-built-in-p'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
288 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
289 Each element has the form (PKG . DESC), where PKG is a package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
290 name (a symbol) and DESC is a vector that describes the package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
291 The vector DESC has the form [VERSION REQS DOCSTRING]. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
292 VERSION is a version list. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
293 REQS is a list of packages (symbols) required by the package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
294 DOCSTRING is a brief description of the package.") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
295 (put 'package--builtins 'risky-local-variable t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
296 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
297 (defvar package-alist nil |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
298 "Alist of all packages available for activation. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
299 Each element has the form (PKG . DESC), where PKG is a package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
300 name (a symbol) and DESC is a vector that describes the package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
301 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
302 The vector DESC has the form [VERSION REQS DOCSTRING]. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
303 VERSION is a version list. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
304 REQS is a list of packages (symbols) required by the package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
305 DOCSTRING is a brief description of the package. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
306 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
307 This variable is set automatically by `package-load-descriptor', |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
308 called via `package-initialize'. To change which packages are |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
309 loaded and/or activated, customize `package-load-list'.") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
310 (put 'package-archive-contents 'risky-local-variable t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
311 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
312 (defvar package-activated-list nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
313 "List of the names of currently activated packages.") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
314 (put 'package-activated-list 'risky-local-variable t) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
315 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
316 (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
|
317 "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
|
318 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
|
319 The inner alist is keyed by version.") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
320 (put 'package-obsolete-alist 'risky-local-variable t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
321 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
322 (defconst package-subdirectory-regexp |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
323 "\\`\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)\\'" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
324 "Regular expression matching the name of a package subdirectory. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
325 The first subexpression is the package name. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
326 The second subexpression is the version string.") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
327 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
328 (defun package-version-join (vlist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
329 "Return the version string corresponding to the list VLIST. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
330 This is, approximately, the inverse of `version-to-list'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
331 \(Actually, it returns only one of the possible inverses, since |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
332 `version-to-list' is a many-to-one operation.)" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
333 (if (null vlist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
334 "" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
335 (let ((str-list (list "." (int-to-string (car vlist))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
336 (dolist (num (cdr vlist)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
337 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
338 ((>= num 0) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
339 (push (int-to-string num) str-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
340 (push "." str-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
341 ((< num -3) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
342 (error "Invalid version list `%s'" vlist)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
343 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
344 ;; pre, or beta, or alpha |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
345 (cond ((equal "." (car str-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
346 (pop str-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
347 ((not (string-match "[0-9]+" (car str-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
348 (error "Invalid version list `%s'" vlist))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
349 (push (cond ((= num -1) "pre") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
350 ((= num -2) "beta") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
351 ((= num -3) "alpha")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
352 str-list)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
353 (if (equal "." (car str-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
354 (pop str-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
355 (apply 'concat (nreverse str-list))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
357 (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
|
358 "Strip the version from a combined package name and version. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
359 E.g., if given \"quux-23.0\", will return \"quux\"" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
360 (if (string-match package-subdirectory-regexp dirname) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
361 (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
|
362 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 (defun package-load-descriptor (dir package) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
364 "Load the description file in directory DIR for package PACKAGE. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
365 Here, PACKAGE is a string of the form NAME-VER, where NAME is the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
366 package name and VER is its version." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
367 (let* ((pkg-dir (expand-file-name package dir)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
368 (pkg-file (expand-file-name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
369 (concat (package-strip-version package) "-pkg") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
370 pkg-dir))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 (when (and (file-directory-p pkg-dir) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
372 (file-exists-p (concat pkg-file ".el"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
373 (load pkg-file nil t)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 (defun package-load-all-descriptors () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
376 "Load descriptors for installed Emacs Lisp packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
377 This looks for package subdirectories in `package-user-dir' and |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
378 `package-directory-list'. The variable `package-load-list' |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
379 controls which package subdirectories may be loaded. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
380 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
381 In each valid package subdirectory, this function loads the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
382 description file containing a call to `define-package', which |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
383 updates `package-alist' and `package-obsolete-alist'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
384 (let ((all (memq 'all package-load-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
385 name version force) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
386 (dolist (dir (cons package-user-dir package-directory-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
387 (when (file-directory-p dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
388 (dolist (subdir (directory-files dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
389 (when (and (file-directory-p (expand-file-name subdir dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
390 (string-match package-subdirectory-regexp subdir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
391 (setq name (intern (match-string 1 subdir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
392 version (match-string 2 subdir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
393 force (assq name package-load-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
394 (when (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
395 ((null force) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
396 all) ; not in package-load-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
397 ((null (setq force (cadr force))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
398 nil) ; disabled |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
399 ((eq force t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
400 t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
401 ((stringp force) ; held |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
402 (version-list-= (version-to-list version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
403 (version-to-list force))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
404 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
405 (error "Invalid element in `package-load-list'"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
406 (package-load-descriptor dir subdir)))))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
407 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 (defsubst package-desc-vers (desc) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
409 "Extract version from a package description vector." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 (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
|
411 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
412 (defsubst package-desc-reqs (desc) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
413 "Extract requirements from a package description vector." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 (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
|
415 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
416 (defsubst package-desc-doc (desc) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
417 "Extract doc string from a package description vector." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 (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
|
419 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 (defsubst package-desc-kind (desc) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
421 "Extract the kind of download from an archive package description vector." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
422 (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
|
423 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
424 (defun package--dir (name version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
425 "Return the directory where a package is installed, or nil if none. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
426 NAME and VERSION are both strings." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
427 (let* ((subdir (concat name "-" version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
428 (dir-list (cons package-user-dir package-directory-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
429 pkg-dir) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
430 (while dir-list |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
431 (let ((subdir-full (expand-file-name subdir (car dir-list)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
432 (if (file-directory-p subdir-full) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
433 (setq pkg-dir subdir-full |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
434 dir-list nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
435 (setq dir-list (cdr dir-list))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
436 pkg-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
437 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
438 (defun package-activate-1 (package pkg-vec) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
439 (let* ((name (symbol-name package)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
440 (version-str (package-version-join (package-desc-vers pkg-vec))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
441 (pkg-dir (package--dir name version-str))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 (unless pkg-dir |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
443 (error "Internal error: unable to find directory for `%s-%s'" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
444 name version-str)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
445 ;; Add info node. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
446 (when (file-exists-p (expand-file-name "dir" pkg-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
447 ;; FIXME: not the friendliest, but simple. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
448 (require 'info) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
449 (info-initialize) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
450 (push pkg-dir Info-directory-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
451 ;; Add to load path, add autoloads, and activate the package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
452 (push pkg-dir load-path) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
453 (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
454 (push package package-activated-list) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
455 ;; 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
|
456 t)) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
458 (defun package-built-in-p (package &optional version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
459 "Return true if PACKAGE, of VERSION or newer, is built-in to Emacs." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
460 (require 'finder-inf nil t) ; For `package--builtins'. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 (let ((elt (assq package package--builtins))) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
462 (and elt (version-list-<= version (package-desc-vers (cdr elt)))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
463 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
464 ;; This function goes ahead and activates a newer version of a package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
465 ;; if an older one was already activated. This is not ideal; we'd at |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
466 ;; least need to check to see if the package has actually been loaded, |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
467 ;; and not merely activated. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
468 (defun package-activate (package version) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
469 "Activate package PACKAGE, of version VERSION or newer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
470 If PACKAGE has any dependencies, recursively activate them. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
471 Return nil if the package could not be activated." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
472 (let ((pkg-vec (cdr (assq package package-alist))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
473 available-version found) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
474 ;; Check if PACKAGE is available in `package-alist'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
475 (when pkg-vec |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
476 (setq available-version (package-desc-vers pkg-vec) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
477 found (version-list-<= version available-version))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
478 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
479 ;; If no such package is found, maybe it's built-in. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
480 ((null found) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
481 (package-built-in-p package version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
482 ;; If the package is already activated, just return t. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
483 ((memq package package-activated-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
484 t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
485 ;; Otherwise, proceed with activation. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
486 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
487 (let ((fail (catch 'dep-failure |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
488 ;; Activate its dependencies recursively. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
489 (dolist (req (package-desc-reqs pkg-vec)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
490 (unless (package-activate (car req) (cadr req)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
491 (throw 'dep-failure req)))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
492 (if fail |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
493 (warn "Unable to activate package `%s'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
494 Required package `%s-%s' is unavailable" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
495 package (car fail) (package-version-join (cadr fail))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
496 ;; If all goes well, activate the package itself. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
497 (package-activate-1 package pkg-vec))))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
498 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
499 (defun package-mark-obsolete (package pkg-vec) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
500 "Put package on the obsolete list, if not already there." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
501 (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
|
502 (if elt |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
503 ;; If this obsolete version does not exist in the list, update |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
504 ;; it the list. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
505 (unless (assoc (package-desc-vers pkg-vec) (cdr elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
506 (setcdr elt (cons (cons (package-desc-vers pkg-vec) pkg-vec) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
507 (cdr elt)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
508 ;; Make a new association. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
509 (push (cons package (list (cons (package-desc-vers pkg-vec) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
510 pkg-vec))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
511 package-obsolete-alist)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
512 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
513 (defun define-package (name-string version-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
514 &optional docstring requirements |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
515 &rest extra-properties) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
516 "Define a new package. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
517 NAME-STRING is the name of the package, as a string. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
518 VERSION-STRING is the version of the package, as a list of |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
519 integers of the form produced by `version-to-list'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
520 DOCSTRING is a short description of the package, a string. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
521 REQUIREMENTS is a list of dependencies on other packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
522 Each requirement is of the form (OTHER-PACKAGE \"VERSION\"). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
523 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
524 EXTRA-PROPERTIES is currently unused." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
525 (let* ((name (intern name-string)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
526 (version (version-to-list version-string)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
527 (new-pkg-desc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
528 (cons name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
529 (vector version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
530 (mapcar |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
531 (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
532 (list (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
533 (version-to-list (car (cdr elt))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
534 requirements) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
535 docstring))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
536 (old-pkg (assq name package-alist))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
537 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
538 ;; If there's no old package, just add this to `package-alist'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
539 ((null old-pkg) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
540 (push new-pkg-desc package-alist)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
541 ((version-list-< (package-desc-vers (cdr old-pkg)) version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
542 ;; Remove the old package and declare it obsolete. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
543 (package-mark-obsolete name (cdr old-pkg)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
544 (setq package-alist (cons new-pkg-desc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
545 (delq old-pkg package-alist)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
546 ;; You can have two packages with the same version, e.g. one in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
547 ;; the system package directory and one in your private |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
548 ;; directory. We just let the first one win. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
549 ((not (version-list-= (package-desc-vers (cdr old-pkg)) version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
550 ;; The package is born obsolete. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
551 (package-mark-obsolete name (cdr new-pkg-desc)))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
552 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
553 ;; 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
|
554 (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
|
555 "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
|
556 (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
|
557 (write-region |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
558 (concat ";;; " (file-name-nondirectory file) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
559 " --- automatically extracted autoloads\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
560 ";;\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
561 ";;; Code:\n\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
562 "\n;; Local Variables:\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
563 ";; version-control: never\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
564 ";; no-byte-compile: t\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
565 ";; no-update-autoloads: t\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
566 ";; End:\n" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
567 ";;; " (file-name-nondirectory file) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
568 " ends here\n") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
569 nil file)) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
570 file) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
571 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
572 (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
|
573 (let* ((auto-name (concat name "-autoloads.el")) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
574 (ignore-name (concat name "-pkg.el")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
575 (generated-autoload-file (expand-file-name auto-name pkg-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
576 (version-control 'never)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
577 (require 'autoload) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
578 (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
|
579 (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
|
580 (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
|
581 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
582 (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
|
583 "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
|
584 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
|
585 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
|
586 `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
|
587 (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
|
588 (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
|
589 (progn |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
590 ;; tar-mode messes with narrowing, so we just let it have the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
591 ;; whole buffer to play with. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
592 (delete-region (point-min) (point)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
593 (tar-mode) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
594 (tar-untar-buffer)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
595 ;; 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
|
596 (call-process-region (point) (point-max) "tar" nil '(nil nil) nil |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
597 "xf" "-"))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
598 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
599 (defun package-unpack (name version) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
600 (let ((pkg-dir (expand-file-name (concat (symbol-name name) "-" version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
601 package-user-dir))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
602 (make-directory package-user-dir t) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
603 ;; FIXME: should we delete PKG-DIR if it exists? |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
604 (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
|
605 (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
|
606 (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
|
607 (let ((load-path (cons pkg-dir load-path))) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
608 (byte-recompile-directory pkg-dir 0 t))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
609 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
610 (defun package--write-file-no-coding (file-name) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
611 (let ((buffer-file-coding-system 'no-conversion)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
612 (write-region (point-min) (point-max) file-name))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
613 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
614 (defun package-unpack-single (file-name version desc requires) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
615 "Install the contents of the current buffer as a package." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
616 ;; Special case "package". |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
617 (if (string= file-name "package") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
618 (package--write-file-no-coding |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
619 (expand-file-name (concat file-name ".el") package-user-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
620 (let* ((pkg-dir (expand-file-name (concat file-name "-" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
621 (package-version-join |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
622 (version-to-list version))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
623 package-user-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
624 (el-file (expand-file-name (concat file-name ".el") pkg-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
625 (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
626 (make-directory pkg-dir t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
627 (package--write-file-no-coding el-file) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
628 (let ((print-level nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
629 (print-length nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
630 (write-region |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
631 (concat |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
632 (prin1-to-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
633 (list 'define-package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
634 file-name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
635 version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
636 desc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
637 (list 'quote |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
638 ;; Turn version lists into string form. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
639 (mapcar |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
640 (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
641 (list (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
642 (package-version-join (cadr elt)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
643 requires)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
644 "\n") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
645 nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
646 pkg-file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
647 nil nil nil 'excl)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
648 (package-generate-autoloads file-name pkg-dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
649 (let ((load-path (cons pkg-dir load-path))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
650 (byte-recompile-directory pkg-dir 0 t))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
651 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
652 (defmacro package--with-work-buffer (location file &rest body) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
653 "Run BODY in a buffer containing the contents of FILE at LOCATION. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
654 LOCATION is the base location of a package archive, and should be |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
655 one of the URLs (or file names) specified in `package-archives'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
656 FILE is the name of a file relative to that base location. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
657 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
658 This macro retrieves FILE from LOCATION into a temporary buffer, |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
659 and evaluates BODY while that buffer is current. This work |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
660 buffer is killed afterwards. Return the last value in BODY." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
661 `(let* ((http (string-match "\\`http:" ,location)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
662 (buffer |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
663 (if http |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
664 (url-retrieve-synchronously (concat ,location ,file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
665 (generate-new-buffer "*package work buffer*")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
666 (prog1 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
667 (with-current-buffer buffer |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
668 (if http |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
669 (progn (package-handle-response) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
670 (re-search-forward "^$" nil 'move) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
671 (forward-char) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
672 (delete-region (point-min) (point))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
673 (unless (file-name-absolute-p ,location) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
674 (error "Archive location %s is not an absolute file name" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
675 ,location)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
676 (insert-file-contents (expand-file-name ,file ,location))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
677 ,@body) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
678 (kill-buffer buffer)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
679 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
680 (defun package-handle-response () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
681 "Handle the response from a `url-retrieve-synchronously' call. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
682 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
|
683 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
|
684 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
|
685 It will move point to somewhere in the headers." |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
686 ;; We assume HTTP here. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
687 (require 'url-http) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
688 (let ((response (url-http-parse-response))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
689 (when (or (< response 200) (>= response 300)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
690 (error "Error during download request:%s" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
691 (buffer-substring-no-properties (point) (progn |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
692 (end-of-line) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
693 (point))))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
694 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
695 (defun package-download-single (name version desc requires) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
696 "Download and install a single-file package." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
697 (let ((location (package-archive-base name)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
698 (file (concat (symbol-name name) "-" version ".el"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
699 (package--with-work-buffer location file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
700 (package-unpack-single (symbol-name name) version desc requires)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
701 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
702 (defun package-download-tar (name version) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
703 "Download and install a tar package." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
704 (let ((location (package-archive-base name)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
705 (file (concat (symbol-name name) "-" version ".tar"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
706 (package--with-work-buffer location file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
707 (package-unpack name version)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
708 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
709 (defun package-installed-p (package &optional min-version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
710 "Return true if PACKAGE, of VERSION or newer, is installed. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
711 Built-in packages also qualify." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
712 (let ((pkg-desc (assq package package-alist))) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
713 (if pkg-desc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
714 (version-list-<= min-version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
715 (package-desc-vers (cdr pkg-desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
716 ;; Also check built-in packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
717 (package-built-in-p package min-version)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
718 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
719 (defun package-compute-transaction (package-list requirements) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
720 "Return a list of packages to be installed, including PACKAGE-LIST. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
721 PACKAGE-LIST should be a list of package names (symbols). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
722 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
723 REQUIREMENTS should be a list of additional requirements; each |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
724 element in this list should have the form (PACKAGE VERSION), |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
725 where PACKAGE is a package name and VERSION is the required |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
726 version of that package (as a list). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
727 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
728 This function recursively computes the requirements of the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
729 packages in REQUIREMENTS, and returns a list of all the packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
730 that must be installed. Packages that are already installed are |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
731 not included in this list." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
732 (dolist (elt requirements) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
733 (let* ((next-pkg (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
734 (next-version (cadr elt))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
735 (unless (package-installed-p next-pkg next-version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
736 ;; A package is required, but not installed. It might also be |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
737 ;; blocked via `package-load-list'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
738 (let ((pkg-desc (assq next-pkg package-archive-contents)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
739 hold) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
740 (when (setq hold (assq next-pkg package-load-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
741 (setq hold (cadr hold)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
742 (cond ((eq hold nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
743 (error "Required package '%s' is disabled" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
744 (symbol-name next-pkg))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
745 ((null (stringp hold)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
746 (error "Invalid element in `package-load-list'")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
747 ((version-list-< (version-to-list hold) next-version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
748 (error "Package `%s' held at version %s, \ |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
749 but version %s required" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
750 (symbol-name next-pkg) hold |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
751 (package-version-join next-version))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
752 (unless pkg-desc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
753 (error "Package `%s-%s' is unavailable" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
754 (symbol-name next-pkg) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
755 (package-version-join next-version))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
756 (unless (version-list-<= next-version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
757 (package-desc-vers (cdr pkg-desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
758 (error |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
759 "Need package `%s-%s', but only %s is available" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
760 (symbol-name next-pkg) (package-version-join next-version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
761 (package-version-join (package-desc-vers (cdr pkg-desc))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
762 ;; Only add to the transaction if we don't already have it. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
763 (unless (memq next-pkg package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
764 (push next-pkg package-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
765 (setq package-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
766 (package-compute-transaction package-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
767 (package-desc-reqs |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
768 (cdr pkg-desc)))))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
769 package-list) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
770 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
771 (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
|
772 "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
|
773 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
|
774 (let* ((read-data (read-from-string str)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
775 (more-left |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
776 (condition-case nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
777 ;; The call to `ignore' suppresses a compiler warning. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
778 (progn (ignore (read-from-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
779 (substring str (cdr read-data)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
780 t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
781 (end-of-file nil)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
782 (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
|
783 (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
|
784 (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
|
785 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
786 (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
|
787 "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
|
788 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
|
789 Will throw an error if the archive version is too new." |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
790 (let ((filename (expand-file-name file package-user-dir))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
791 (when (file-exists-p filename) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
792 (with-temp-buffer |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
793 (insert-file-contents-literally filename) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
794 (let ((contents (read (current-buffer)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
795 (if (> (car contents) package-archive-version) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
796 (error "Package archive version %d is higher than %d" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
797 (car contents) package-archive-version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
798 (cdr contents)))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
799 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
800 (defun package-read-all-archive-contents () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
801 "Re-read `archive-contents', if it exists. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
802 If successful, set `package-archive-contents'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
803 (setq package-archive-contents nil) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
804 (dolist (archive package-archives) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
805 (package-read-archive-contents (car archive)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
806 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
807 (defun package-read-archive-contents (archive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
808 "Re-read archive contents for ARCHIVE. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
809 If successful, set the variable `package-archive-contents'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
810 If the archive version is too new, signal an error." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
811 ;; Version 1 of 'archive-contents' is identical to our internal |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
812 ;; representation. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
813 (let* ((dir (concat "archives/" archive)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
814 (contents-file (concat dir "/archive-contents")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
815 contents) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
816 (when (setq contents (package--read-archive-file contents-file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
817 (dolist (package contents) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
818 (package--add-to-archive-contents package archive))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
819 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
820 (defun package--add-to-archive-contents (package archive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
821 "Add the PACKAGE from the given ARCHIVE if necessary. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
822 Also, add the originating archive to the end of the package vector." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
823 (let* ((name (car package)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
824 (version (aref (cdr package) 0)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
825 (entry (cons (car package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
826 (vconcat (cdr package) (vector archive)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
827 (existing-package (cdr (assq name package-archive-contents)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
828 (when (or (not existing-package) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
829 (version-list-< (aref existing-package 0) version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
830 (add-to-list 'package-archive-contents entry)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
831 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
832 (defun package-download-transaction (package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
833 "Download and install all the packages in PACKAGE-LIST. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
834 PACKAGE-LIST should be a list of package names (symbols). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
835 This function assumes that all package requirements in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
836 PACKAGE-LIST are satisfied, i.e. that PACKAGE-LIST is computed |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
837 using `package-compute-transaction'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
838 (dolist (elt package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
839 (let* ((desc (cdr (assq elt package-archive-contents))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
840 ;; As an exception, if package is "held" in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
841 ;; `package-load-list', download the held version. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
842 (hold (cadr (assq elt package-load-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
843 (v-string (or (and (stringp hold) hold) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
844 (package-version-join (package-desc-vers desc)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
845 (kind (package-desc-kind desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
846 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
847 ((eq kind 'tar) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
848 (package-download-tar elt v-string)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
849 ((eq kind 'single) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
850 (package-download-single elt v-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
851 (package-desc-doc desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
852 (package-desc-reqs desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
853 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
854 (error "Unknown package kind: %s" (symbol-name kind))))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
855 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
856 ;;;###autoload |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
857 (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
|
858 "Install the package named NAME. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
859 Interactively, prompt for the package name. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
860 The package is found on one of the archives in `package-archives'." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
861 (interactive |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
862 (list (intern (completing-read "Install package: " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
863 (mapcar (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
864 (cons (symbol-name (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
865 nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
866 package-archive-contents) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
867 nil t)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
868 (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
|
869 (unless pkg-desc |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
870 (error "Package `%s' is not available for installation" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
871 (symbol-name name))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
872 (package-download-transaction |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
873 (package-compute-transaction (list name) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
874 (package-desc-reqs (cdr pkg-desc))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
875 ;; 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
|
876 (package-initialize)) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
877 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
878 (defun package-strip-rcs-id (str) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
879 "Strip RCS version ID from the version string STR. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
880 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
|
881 Otherwise return nil." |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
882 (when str |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
883 (when (string-match "\\`[ \t]*[$]Revision:[ \t]+" str) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
884 (setq str (substring str (match-end 0)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
885 (condition-case nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
886 (if (version-to-list str) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
887 str) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
888 (error nil)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
889 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
890 (defun package-buffer-info () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
891 "Return a vector describing the package in the current buffer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
892 The vector has the form |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
893 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
894 [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY] |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
895 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
896 FILENAME is the file name, a string, sans the \".el\" extension. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
897 REQUIRES is a requires list, or nil. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
898 DESCRIPTION is the package description, a string. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
899 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
|
900 COMMENTARY is the commentary section, a string, or nil if none. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
901 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
902 If the buffer does not contain a conforming package, signal an |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
903 error. If there is a package, narrow the buffer to the file's |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
904 boundaries." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
905 (goto-char (point-min)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
906 (unless (re-search-forward "^;;; \\([^ ]*\\)\\.el --- \\(.*\\)$" nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
907 (error "Packages lacks a file header")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
908 (let ((file-name (match-string-no-properties 1)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
909 (desc (match-string-no-properties 2)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
910 (start (line-beginning-position))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
911 (unless (search-forward (concat ";;; " file-name ".el ends here")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
912 (error "Package lacks a terminating comment")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
913 ;; Try to include a trailing newline. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
914 (forward-line) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
915 (narrow-to-region start (point)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
916 (require 'lisp-mnt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
917 ;; Use some headers we've invented to drive the process. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
918 (let* ((requires-str (lm-header "package-requires")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
919 (requires (if requires-str |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
920 (package-read-from-string requires-str))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
921 ;; Prefer Package-Version; if defined, the package author |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
922 ;; probably wants us to use it. Otherwise try Version. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
923 (pkg-version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
924 (or (package-strip-rcs-id (lm-header "package-version")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
925 (package-strip-rcs-id (lm-header "version")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
926 (commentary (lm-commentary))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
927 (unless pkg-version |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
928 (error |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
929 "Package lacks a \"Version\" or \"Package-Version\" header")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
930 ;; Turn string version numbers into list form. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
931 (setq requires |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
932 (mapcar |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
933 (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
934 (list (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
935 (version-to-list (car (cdr elt))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
936 requires)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
937 (vector file-name requires desc pkg-version commentary)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
938 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
939 (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
|
940 "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
|
941 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
|
942 The return result is a vector like `package-buffer-info'." |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
943 (let ((default-directory (file-name-directory file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
944 (file (file-name-nondirectory file))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
945 (unless (string-match "^\\(.+\\)-\\([0-9.]+\\)\\.tar$" file) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
946 (error "Invalid package name `%s'" file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
947 (let* ((pkg-name (match-string-no-properties 1 file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
948 (pkg-version (match-string-no-properties 2 file)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
949 ;; Extract the package descriptor. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
950 (pkg-def-contents (shell-command-to-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
951 ;; Requires GNU tar. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
952 (concat "tar -xOf " file " " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
953 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
954 pkg-name "-" pkg-version "/" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
955 pkg-name "-pkg.el"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
956 (pkg-def-parsed (package-read-from-string pkg-def-contents))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
957 (unless (eq (car pkg-def-parsed) 'define-package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
958 (error "No `define-package' sexp is present in `%s-pkg.el'" pkg-name)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
959 (let ((name-str (nth 1 pkg-def-parsed)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
960 (version-string (nth 2 pkg-def-parsed)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
961 (docstring (nth 3 pkg-def-parsed)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
962 (requires (nth 4 pkg-def-parsed)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
963 (readme (shell-command-to-string |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
964 ;; Requires GNU tar. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
965 (concat "tar -xOf " file " " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
966 pkg-name "-" pkg-version "/README")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
967 (unless (equal pkg-version version-string) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
968 (error "Package has inconsistent versions")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
969 (unless (equal pkg-name name-str) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
970 (error "Package has inconsistent names")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
971 ;; Kind of a hack. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
972 (if (string-match ": Not found in archive" readme) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
973 (setq readme nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
974 ;; Turn string version numbers into list form. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
975 (if (eq (car requires) 'quote) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
976 (setq requires (car (cdr requires)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
977 (setq requires |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
978 (mapcar (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
979 (list (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
980 (version-to-list (cadr elt)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
981 requires)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
982 (vector pkg-name requires docstring version-string readme))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
983 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
984 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
985 (defun package-install-from-buffer (pkg-info type) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
986 "Install a package from the current buffer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
987 When called interactively, the current buffer is assumed to be a |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
988 single .el file that follows the packaging guidelines; see info |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
989 node `(elisp)Packaging'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
990 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
991 When called from Lisp, PKG-INFO is a vector describing the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
992 information, of the type returned by `package-buffer-info'; and |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
993 TYPE is the package type (either `single' or `tar')." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
994 (interactive (list (package-buffer-info) 'single)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
995 (save-excursion |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
996 (save-restriction |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
997 (let* ((file-name (aref pkg-info 0)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
998 (requires (aref pkg-info 1)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
999 (desc (if (string= (aref pkg-info 2) "") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1000 "No description available." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1001 (aref pkg-info 2))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1002 (pkg-version (aref pkg-info 3))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1003 ;; Download and install the dependencies. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1004 (let ((transaction (package-compute-transaction nil requires))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1005 (package-download-transaction transaction)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1006 ;; Install the package itself. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1007 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1008 ((eq type 'single) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1009 (package-unpack-single file-name pkg-version desc requires)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1010 ((eq type 'tar) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1011 (package-unpack (intern file-name) pkg-version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1012 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1013 (error "Unknown type: %s" (symbol-name type)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1014 ;; Try to activate it. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1015 (package-initialize))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1016 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1017 ;;;###autoload |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1018 (defun package-install-file (file) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1019 "Install a package from a file. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1020 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
|
1021 (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
|
1022 (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
|
1023 (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
|
1024 (cond |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1025 ((string-match "\\.el$" file) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1026 (package-install-from-buffer (package-buffer-info) 'single)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1027 ((string-match "\\.tar$" file) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1028 (package-install-from-buffer (package-tar-file-info file) 'tar)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1029 (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
|
1030 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1031 (defun package-delete (name version) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1032 (let ((dir (package--dir name version))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1033 (if (string-equal (file-name-directory dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1034 (file-name-as-directory |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1035 (expand-file-name package-user-dir))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1036 (progn |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1037 (delete-directory dir t t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1038 (message "Package `%s-%s' deleted." name version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1039 ;; Don't delete "system" packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1040 (error "Package `%s-%s' is a system package, not deleting" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1041 name version)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1042 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1043 (defun package-archive-base (name) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1044 "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
|
1045 (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
|
1046 (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
|
1047 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1048 (defun package--download-one-archive (archive file) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1049 "Retrieve an archive file FILE from ARCHIVE, and cache it. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1050 ARCHIVE should be a cons cell of the form (NAME . LOCATION), |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1051 similar to an entry in `package-alist'. Save the cached copy to |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1052 \"archives/NAME/archive-contents\" in `package-user-dir'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1053 (let* ((dir (expand-file-name "archives" package-user-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1054 (dir (expand-file-name (car archive) dir))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1055 (package--with-work-buffer (cdr archive) file |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1056 ;; Read the retrieved buffer to make sure it is valid (e.g. it |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1057 ;; may fetch a URL redirect page). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1058 (when (listp (read buffer)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1059 (make-directory dir t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1060 (setq buffer-file-name (expand-file-name file dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1061 (let ((version-control 'never)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1062 (save-buffer)))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1063 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1064 (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
|
1065 "Download the ELPA archive description if needed. |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1066 This informs Emacs about the latest versions of all packages, and |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1067 makes them available for download." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1068 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1069 (unless (file-exists-p package-user-dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1070 (make-directory package-user-dir t)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1071 (dolist (archive package-archives) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1072 (condition-case-no-debug nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1073 (package--download-one-archive archive "archive-contents") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1074 (error (message "Failed to download `%s' archive." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1075 (car archive))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1076 (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
|
1077 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1078 (defvar package--initialized nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1079 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1080 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1081 (defun package-initialize (&optional no-activate) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1082 "Load Emacs Lisp packages, and activate them. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1083 The variable `package-load-list' controls which packages to load. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1084 If optional arg NO-ACTIVATE is non-nil, don't activate packages." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1085 (interactive) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1086 (setq package-alist nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1087 package-obsolete-alist nil) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1088 (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
|
1089 (package-read-all-archive-contents) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1090 (unless no-activate |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1091 (dolist (elt package-alist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1092 (package-activate (car elt) (package-desc-vers (cdr elt))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1093 (setq package--initialized t)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1094 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1095 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1096 ;;;; Package description buffer. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1097 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1098 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1099 (defun describe-package (package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1100 "Display the full documentation of PACKAGE (a symbol)." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1101 (interactive |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1102 (let* ((guess (function-called-at-point)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1103 packages val) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1104 (require 'finder-inf nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1105 ;; Load the package list if necessary (but don't activate them). |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1106 (unless package--initialized |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1107 (package-initialize t)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1108 (setq packages (append (mapcar 'car package-alist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1109 (mapcar 'car package-archive-contents) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1110 (mapcar 'car package--builtins))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1111 (unless (memq guess packages) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1112 (setq guess nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1113 (setq packages (mapcar 'symbol-name packages)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1114 (setq val |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1115 (completing-read (if guess |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1116 (format "Describe package (default %s): " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1117 guess) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1118 "Describe package: ") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1119 packages nil t nil nil guess)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1120 (list (if (equal val "") guess (intern val))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1121 (if (or (null package) (not (symbolp package))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1122 (message "No package specified") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1123 (help-setup-xref (list #'describe-package package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1124 (called-interactively-p 'interactive)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1125 (with-help-window (help-buffer) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1126 (with-current-buffer standard-output |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1127 (describe-package-1 package))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1128 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1129 (defun describe-package-1 (package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1130 (require 'lisp-mnt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1131 (let ((package-name (symbol-name package)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1132 (built-in (assq package package--builtins)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1133 desc pkg-dir reqs version installable) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1134 (prin1 package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1135 (princ " is ") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1136 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1137 ;; Loaded packages are in `package-alist'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1138 ((setq desc (cdr (assq package package-alist))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1139 (setq version (package-version-join (package-desc-vers desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1140 (if (setq pkg-dir (package--dir package-name version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1141 (insert "an installed package.\n\n") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1142 ;; This normally does not happen. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1143 (insert "a deleted package.\n\n"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1144 ;; Available packages are in `package-archive-contents'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1145 ((setq desc (cdr (assq package package-archive-contents))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1146 (setq version (package-version-join (package-desc-vers desc)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1147 installable t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1148 (if built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1149 (insert "a built-in package.\n\n") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1150 (insert "an uninstalled package.\n\n"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1151 (built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1152 (setq desc (cdr built-in) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1153 version (package-version-join (package-desc-vers desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1154 (insert "a built-in package.\n\n")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1155 (t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1156 (insert "an orphan package.\n\n"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1157 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1158 (insert " " (propertize "Status" 'font-lock-face 'bold) ": ") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1159 (cond (pkg-dir |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1160 (insert (propertize "Installed" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1161 'font-lock-face 'font-lock-comment-face)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1162 (insert " in `") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1163 ;; Todo: Add button for uninstalling. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1164 (help-insert-xref-button (file-name-as-directory pkg-dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1165 'help-package-def pkg-dir) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1166 (if built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1167 (insert "',\n shadowing a " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1168 (propertize "built-in package" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1169 'font-lock-face 'font-lock-builtin-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1170 ".") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1171 (insert "'."))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1172 (installable |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1173 (if built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1174 (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1175 " Alternate version available -- ") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1176 (insert "Available -- ")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1177 (let ((button-text (if (display-graphic-p) "Install" "[Install]")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1178 (button-face (if (display-graphic-p) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1179 '(:box (:line-width 2 :color "dark grey") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1180 :background "light grey" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1181 :foreground "black") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1182 'link))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1183 (insert-text-button button-text 'face button-face 'follow-link t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1184 'package-symbol package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1185 'action 'package-install-button-action))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1186 (built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1187 (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1188 (t (insert "Deleted."))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1189 (insert "\n") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1190 (and version (> (length version) 0) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1191 (insert " " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1192 (propertize "Version" 'font-lock-face 'bold) ": " version "\n")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1193 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1194 (setq reqs (if desc (package-desc-reqs desc))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1195 (when reqs |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1196 (insert " " (propertize "Requires" 'font-lock-face 'bold) ": ") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1197 (let ((first t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1198 name vers text) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1199 (dolist (req reqs) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1200 (setq name (car req) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1201 vers (cadr req) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1202 text (format "%s-%s" (symbol-name name) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1203 (package-version-join vers))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1204 (cond (first (setq first nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1205 ((>= (+ 2 (current-column) (length text)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1206 (window-width)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1207 (insert ",\n ")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1208 (t (insert ", "))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1209 (help-insert-xref-button text 'help-package name)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1210 (insert "\n"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1211 (insert " " (propertize "Summary" 'font-lock-face 'bold) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1212 ": " (if desc (package-desc-doc desc)) "\n\n") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1213 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1214 (if built-in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1215 ;; For built-in packages, insert the commentary. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1216 (let ((fn (locate-file (concat package-name ".el") load-path |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1217 load-file-rep-suffixes)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1218 (opoint (point))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1219 (insert (or (lm-commentary fn) "")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1220 (save-excursion |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1221 (goto-char opoint) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1222 (when (re-search-forward "^;;; Commentary:\n" nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1223 (replace-match "")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1224 (while (re-search-forward "^\\(;+ ?\\)" nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1225 (replace-match "")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1226 (let ((readme (expand-file-name (concat package-name "-readme.txt") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1227 package-user-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1228 readme-string) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1229 ;; For elpa packages, try downloading the commentary. If that |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1230 ;; fails, try an existing readme file in `package-user-dir'. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1231 (cond ((condition-case nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1232 (package--with-work-buffer (package-archive-base package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1233 (concat package-name "-readme.txt") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1234 (setq buffer-file-name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1235 (expand-file-name readme package-user-dir)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1236 (let ((version-control 'never)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1237 (save-buffer)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1238 (setq readme-string (buffer-string)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1239 t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1240 (error nil)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1241 (insert readme-string)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1242 ((file-readable-p readme) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1243 (insert-file-contents readme) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1244 (goto-char (point-max)))))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1245 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1246 (defun package-install-button-action (button) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1247 (let ((package (button-get button 'package-symbol))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1248 (when (y-or-n-p (format "Install package `%s'? " package)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1249 (package-install package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1250 (revert-buffer nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1251 (goto-char (point-min))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1252 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1253 |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1254 ;;;; 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
|
1255 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1256 (defvar package-menu-mode-map |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1257 (let ((map (copy-keymap special-mode-map)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1258 (menu-map (make-sparse-keymap "Package"))) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1259 (set-keymap-parent map button-buffer-map) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1260 (define-key map "\C-m" 'package-menu-describe-package) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1261 (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
|
1262 (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
|
1263 (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
|
1264 (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
|
1265 (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
|
1266 (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
|
1267 (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
|
1268 (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
|
1269 (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
|
1270 (define-key map "h" 'package-menu-quick-help) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1271 (define-key map "?" 'package-menu-describe-package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1272 (define-key map [follow-link] 'mouse-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1273 (define-key map [mouse-2] 'mouse-select-window) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1274 (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
|
1275 (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
|
1276 '(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
|
1277 :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
|
1278 (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
|
1279 (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
|
1280 '(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
|
1281 :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
|
1282 (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
|
1283 '(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
|
1284 :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
|
1285 (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
|
1286 (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
|
1287 '(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
|
1288 :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
|
1289 (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
|
1290 '(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
|
1291 :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
|
1292 (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
|
1293 '(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
|
1294 :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
|
1295 (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
|
1296 '(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
|
1297 :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
|
1298 (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
|
1299 (define-key menu-map [mg] |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1300 '(menu-item "Update package list" revert-buffer |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1301 :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
|
1302 (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
|
1303 '(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
|
1304 :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
|
1305 (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
|
1306 (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
|
1307 '(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
|
1308 :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
|
1309 (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
|
1310 '(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
|
1311 :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
|
1312 (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
|
1313 (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
|
1314 '(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
|
1315 :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
|
1316 (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
|
1317 '(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
|
1318 :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
|
1319 map) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1320 "Local keymap for `package-menu-mode' buffers.") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1321 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1322 (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
|
1323 (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
|
1324 (define-key map [header-line mouse-1] 'package-menu-sort-by-column) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1325 (define-key map [header-line mouse-2] 'package-menu-sort-by-column) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1326 (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
|
1327 map) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1328 "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
|
1329 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1330 (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
|
1331 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1332 (define-derived-mode package-menu-mode special-mode "Package Menu" |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1333 "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
|
1334 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
|
1335 \\<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
|
1336 \\{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
|
1337 (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
|
1338 (setq buffer-read-only t) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1339 (set (make-local-variable 'revert-buffer-function) 'package-menu-revert) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1340 (setq header-line-format |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1341 (mapconcat |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1342 (lambda (pair) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1343 (let ((column (car pair)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1344 (name (cdr pair))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1345 (concat |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1346 ;; Insert a space that aligns the button properly. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1347 (propertize " " 'display (list 'space :align-to column) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1348 'face 'fixed-pitch) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1349 ;; Set up the column button. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1350 (propertize name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1351 'column-name name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1352 'help-echo "mouse-1: sort by column" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1353 'mouse-face 'highlight |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1354 'keymap package-menu-sort-button-map)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1355 ;; We take a trick from buff-menu and have a dummy leading |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1356 ;; space to align the header line with the beginning of the |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1357 ;; text. This doesn't really work properly on Emacs 21, but |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1358 ;; it is close enough. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1359 '((0 . "") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1360 (2 . "Package") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1361 (20 . "Version") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1362 (32 . "Status") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1363 (43 . "Description")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1364 ""))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1365 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1366 (defun package-menu-refresh () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1367 "Download the Emacs Lisp package archive. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1368 This fetches the contents of each archive specified in |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1369 `package-archives', and then refreshes the package menu." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1370 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1371 (unless (eq major-mode 'package-menu-mode) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1372 (error "The current buffer is not a Package Menu")) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1373 (package-refresh-contents) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1374 (package--generate-package-list)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1375 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1376 (defun package-menu-revert (&optional arg noconfirm) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1377 "Update the list of packages. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1378 This function is the `revert-buffer-function' for Package Menu |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1379 buffers. The arguments are ignored." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1380 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1381 (unless (eq major-mode 'package-menu-mode) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1382 (error "The current buffer is not a Package Menu")) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1383 (package--generate-package-list)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1384 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1385 (defun package-menu-describe-package () |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1386 "Describe the package in the current line." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1387 (interactive) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1388 (let ((name (package-menu-get-package))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1389 (if name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1390 (describe-package (intern name)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1391 (message "No package on this line")))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1392 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1393 (defun package-menu-mark-internal (what) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1394 (unless (eobp) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1395 (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
|
1396 (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
|
1397 (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
|
1398 (insert what) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1399 (forward-line)))) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1400 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1401 ;; fixme numeric argument |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1402 (defun package-menu-mark-delete (num) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1403 "Mark a package for deletion and move to the next line." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1404 (interactive "p") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1405 (if (string-equal (package-menu-get-status) "installed") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1406 (package-menu-mark-internal "D") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1407 (forward-line))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1408 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1409 (defun package-menu-mark-install (num) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1410 "Mark a package for installation and move to the next line." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1411 (interactive "p") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1412 (if (string-equal (package-menu-get-status) "available") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1413 (package-menu-mark-internal "I") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1414 (forward-line))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1415 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1416 (defun package-menu-mark-unmark (num) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1417 "Clear any marks on a package and move to the next line." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1418 (interactive "p") |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1419 (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
|
1420 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1421 (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
|
1422 "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
|
1423 (interactive) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1424 (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
|
1425 (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
|
1426 (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
|
1427 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1428 (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
|
1429 "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
|
1430 (interactive) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1431 (save-excursion |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1432 (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
|
1433 (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
|
1434 (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
|
1435 (if (looking-at ".*\\s obsolete\\s ") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1436 (package-menu-mark-internal "D") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1437 (forward-line 1))))) |
211
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 (defun package-menu-quick-help () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1440 "Show short key binding help for package-menu-mode." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1441 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1442 (message "n-ext, i-nstall, d-elete, u-nmark, x-ecute, r-efresh, h-elp")) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1443 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1444 (define-obsolete-function-alias |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1445 'package-menu-view-commentary 'package-menu-describe-package "24.1") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1446 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1447 ;; Return the name of the package on the current line. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1448 (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
|
1449 (save-excursion |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1450 (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
|
1451 (if (looking-at ". \\([^ \t]*\\)") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1452 (match-string-no-properties 1)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1453 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1454 ;; Return the version of the package on the current line. |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1455 (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
|
1456 (save-excursion |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1457 (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
|
1458 (if (looking-at ". [^ \t]*[ \t]*\\([0-9.]*\\)") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1459 (match-string 1)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1460 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1461 (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
|
1462 (save-excursion |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1463 (if (looking-at ". [^ \t]*[ \t]*[^ \t]*[ \t]*\\([^ \t]*\\)") |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1464 (match-string 1) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1465 ""))) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1466 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1467 (defun package-menu-execute () |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1468 "Perform marked Package Menu actions. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1469 Packages marked for installation are downloaded and installed; |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1470 packages marked for deletion are removed." |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1471 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1472 (let (install-list delete-list cmd) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1473 (save-excursion |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1474 (goto-char (point-min)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1475 (while (not (eobp)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1476 (setq cmd (char-after)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1477 (cond |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1478 ((eq cmd ?\s) t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1479 ((eq cmd ?D) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1480 (push (cons (package-menu-get-package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1481 (package-menu-get-version)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1482 delete-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1483 ((eq cmd ?I) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1484 (push (package-menu-get-package) install-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1485 (forward-line))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1486 ;; Delete packages, prompting if necessary. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1487 (when delete-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1488 (if (yes-or-no-p |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1489 (if (= (length delete-list) 1) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1490 (format "Delete package `%s-%s'? " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1491 (caar delete-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1492 (cdr (car delete-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1493 (format "Delete these %d packages (%s)? " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1494 (length delete-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1495 (mapconcat (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1496 (concat (car elt) "-" (cdr elt))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1497 delete-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1498 ", ")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1499 (dolist (elt delete-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1500 (condition-case-no-debug err |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1501 (package-delete (car elt) (cdr elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1502 (error (message (cadr err))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1503 (error "Aborted"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1504 (when install-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1505 (if (yes-or-no-p |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1506 (if (= (length install-list) 1) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1507 (format "Install package `%s'? " (car install-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1508 (format "Install these %d packages (%s)? " |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1509 (length install-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1510 (mapconcat 'identity install-list ", ")))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1511 (dolist (elt install-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1512 (package-install (intern elt))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1513 ;; If we deleted anything, regenerate `package-alist'. This is done |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1514 ;; automatically if we installed a package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1515 (and delete-list (null install-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1516 (package-initialize)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1517 (if (or delete-list install-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1518 (package-menu-revert) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1519 (message "No operations specified.")))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1520 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1521 (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
|
1522 (let ((face |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1523 (cond ((string= key "built-in") 'font-lock-builtin-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1524 ((string= key "available") 'default) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1525 ((string= key "held") 'font-lock-constant-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1526 ((string= key "disabled") 'font-lock-warning-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1527 ((string= key "installed") 'font-lock-comment-face) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1528 (t ; obsolete, but also the default. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1529 'font-lock-warning-face)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1530 (insert (propertize " " 'font-lock-face face)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1531 (insert-text-button (symbol-name package) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1532 'face 'link |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1533 'follow-link t |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1534 'package-symbol package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1535 'action (lambda (button) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1536 (describe-package |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1537 (button-get button 'package-symbol)))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1538 (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
|
1539 (insert (propertize (package-version-join version) 'font-lock-face face)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1540 (indent-to 32 1) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1541 (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
|
1542 ;; 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
|
1543 (when desc |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1544 (indent-to 43 1) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1545 (let ((opoint (point))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1546 (insert (propertize desc 'font-lock-face face)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1547 (upcase-region opoint (min (point) (1+ opoint))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1548 (insert "\n"))) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1549 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1550 (defun package-list-maybe-add (package version status description result) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1551 (unless (assoc (cons package version) result) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1552 (push (list (cons package version) status description) result)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1553 result) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1554 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1555 (defvar package-menu-package-list nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1556 "List of packages to display in the Package Menu buffer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1557 A value of nil means to display all packages.") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1558 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1559 (defvar package-menu-sort-key nil |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1560 "Sort key for the current Package Menu buffer.") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1561 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1562 (defun package--generate-package-list () |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1563 "Populate the current Package Menu buffer." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1564 (let ((inhibit-read-only t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1565 info-list name desc hold builtin) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1566 (erase-buffer) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1567 ;; List installed packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1568 (dolist (elt package-alist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1569 (setq name (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1570 (when (or (null package-menu-package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1571 (memq name package-menu-package-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1572 (setq desc (cdr elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1573 hold (cadr (assq name package-load-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1574 (setq info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1575 (package-list-maybe-add |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1576 name (package-desc-vers desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1577 ;; FIXME: it turns out to be tricky to see if this |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1578 ;; package is presently activated. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1579 (if (stringp hold) "held" "installed") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1580 (package-desc-doc desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1581 info-list)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1582 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1583 ;; List built-in packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1584 (dolist (elt package--builtins) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1585 (setq name (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1586 (when (and (not (eq name 'emacs)) ; Hide the `emacs' package. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1587 (or (null package-menu-package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1588 (memq name package-menu-package-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1589 (setq desc (cdr elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1590 (setq info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1591 (package-list-maybe-add |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1592 name (package-desc-vers desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1593 "built-in" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1594 (package-desc-doc desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1595 info-list)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1596 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1597 ;; List available and disabled packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1598 (dolist (elt package-archive-contents) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1599 (setq name (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1600 desc (cdr elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1601 hold (assq name package-load-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1602 (when (or (null package-menu-package-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1603 (memq name package-menu-package-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1604 (setq info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1605 (package-list-maybe-add name |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1606 (package-desc-vers desc) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1607 (if (and hold (null (cadr hold))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1608 "disabled" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1609 "available") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1610 (package-desc-doc (cdr elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1611 info-list)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1612 ;; List obsolete packages |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1613 (mapc (lambda (elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1614 (mapc (lambda (inner-elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1615 (setq info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1616 (package-list-maybe-add (car elt) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1617 (package-desc-vers |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1618 (cdr inner-elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1619 "obsolete" |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1620 (package-desc-doc |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1621 (cdr inner-elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1622 info-list))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1623 (cdr elt))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1624 package-obsolete-alist) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1625 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1626 (setq info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1627 (sort info-list |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1628 (cond ((string= package-menu-sort-key "Package") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1629 'package-menu--name-predicate) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1630 ((string= package-menu-sort-key "Version") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1631 'package-menu--version-predicate) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1632 ((string= package-menu-sort-key "Description") |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1633 'package-menu--description-predicate) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1634 (t ; By default, sort by package status |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1635 'package-menu--status-predicate)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1636 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1637 (dolist (elt info-list) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1638 (package-print-package (car (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1639 (cdr (car elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1640 (car (cdr elt)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1641 (car (cdr (cdr elt))))) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1642 (goto-char (point-min)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1643 (set-buffer-modified-p nil) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1644 (current-buffer))) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1645 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1646 (defun package-menu--version-predicate (left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1647 (let ((vleft (or (cdr (car left)) '(0))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1648 (vright (or (cdr (car right)) '(0)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1649 (if (version-list-= vleft vright) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1650 (package-menu--name-predicate left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1651 (version-list-< vleft vright)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1652 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1653 (defun package-menu--status-predicate (left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1654 (let ((sleft (cadr left)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1655 (sright (cadr right))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1656 (cond ((string= sleft sright) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1657 (package-menu--name-predicate left right)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1658 ((string= sleft "available") t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1659 ((string= sright "available") nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1660 ((string= sleft "installed") t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1661 ((string= sright "installed") nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1662 ((string= sleft "held") t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1663 ((string= sright "held") nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1664 ((string= sleft "built-in") t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1665 ((string= sright "built-in") nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1666 ((string= sleft "obsolete") t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1667 ((string= sright "obsolete") nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1668 (t (string< sleft sright))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1669 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1670 (defun package-menu--description-predicate (left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1671 (let ((sleft (car (cddr left))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1672 (sright (car (cddr right)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1673 (if (string= sleft sright) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1674 (package-menu--name-predicate left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1675 (string< sleft sright)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1676 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1677 (defun package-menu--name-predicate (left right) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1678 (string< (symbol-name (caar left)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1679 (symbol-name (caar right)))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1680 |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1681 (defun package-menu-sort-by-column (&optional e) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1682 "Sort the package menu by the column of the mouse click E." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1683 (interactive "e") |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1684 (let* ((pos (event-start e)) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1685 (obj (posn-object pos)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1686 (col (if obj |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1687 (get-text-property (cdr obj) 'column-name (car obj)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1688 (get-text-property (posn-point pos) 'column-name))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1689 (buf (window-buffer (posn-window (event-start e))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1690 (with-current-buffer buf |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1691 (when (eq major-mode 'package-menu-mode) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1692 (setq package-menu-sort-key col) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1693 (package--generate-package-list))))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1694 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1695 (defun package--list-packages (&optional packages) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1696 "Generate and pop to the *Packages* buffer. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1697 Optional PACKAGES is a list of names of packages (symbols) to |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1698 list; the default is to display everything in `package-alist'." |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1699 (require 'finder-inf nil t) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1700 (let ((buf (get-buffer-create "*Packages*"))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1701 (with-current-buffer buf |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1702 (package-menu-mode) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1703 (set (make-local-variable 'package-menu-package-list) packages) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1704 (set (make-local-variable 'package-menu-sort-key) nil) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1705 (package--generate-package-list)) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1706 ;; The package menu buffer has keybindings. If the user types |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1707 ;; `M-x list-packages', that suggests it should become current. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1708 (switch-to-buffer buf))) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1709 |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1710 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1711 (defun list-packages () |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1712 "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
|
1713 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
|
1714 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
|
1715 (interactive) |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1716 ;; Initialize the package system if necessary. |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1717 (unless package--initialized |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1718 (package-initialize t)) |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1719 (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
|
1720 (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
|
1721 |
336
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1722 ;;;###autoload |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1723 (defalias 'package-list-packages 'list-packages) |
ea73ef5dc38c
emacs: avoid weird package.el breakage with newish packages
Augie Fackler <raf@durin42.com>
parents:
211
diff
changeset
|
1724 |
211
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1725 (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
|
1726 "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
|
1727 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
|
1728 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
|
1729 (interactive) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1730 (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
|
1731 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1732 (provide 'package) |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1733 |
8980dc2deda0
emacs: use package.el to bootstrap instead of checking in all needed libs
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1734 ;;; package.el ends here |