annotate lisp/packages.el @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children ca9a9ec9c1c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; packages.el --- Low level support for XEmacs packages
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Steven L Baur <steve@altair.xemacs.org>
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
6 ;; Maintainer: Steven L Baur <steve@altair.xemacs.org>
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: internal, lisp, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;; This file provides low level facilities for XEmacs startup --
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;; particularly regarding the package setup. This code has to run in
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 ;; environment. Pay special attention:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 ;; (this goes for any package loaded before `subr.el'.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 ;; - not to use macros, because they are not yet available (and this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 ;; file must be loadable uncompiled.) This rules out CL-style
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 ;; macros like `when', for instance.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 ;; - not to use `defcustom'. If you must add user-customizable
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 ;; variables here, use `defvar', and add the variable to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 ;; `cus-start.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 ;; Because of all this, make sure that the stuff you put here really
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 ;; belongs here.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
51 ;; This file requires find-paths.el.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
55 ;;; Package versioning
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
56
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
57 (defvar packages-package-list nil
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
58 "database of loaded packages and version numbers")
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
59
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
60 (defvar early-packages nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
61 "Packages early in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
62
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
63 (defvar early-package-load-path nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
64 "Load path for packages early in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
65
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
66 (defvar late-packages nil
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
67 "Packages late in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
68
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
69 (defvar late-package-load-path nil
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
70 "Load path for packages late in the load path.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
71
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
72 (defvar last-packages nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
73 "Packages last in the load path.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
74
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
75 (defvar last-package-load-path nil
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
76 "Load path for packages last in the load path.")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
77
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
78 (defun package-get-key-1 (info key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
79 "Locate keyword `key' in list."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
80 (cond ((null info)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
81 nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
82 ((eq (car info) key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
83 (nth 1 info))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
84 (t (package-get-key-1 (cddr info) key))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
85
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
86 (defun package-get-key (name key)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
87 "Get info `key' from package `name'."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
88 (let ((info (assq name packages-package-list)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
89 (when info
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
90 (package-get-key-1 (cdr info) key))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
91
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
92 (defun package-provide (name &rest attributes)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
93 (let ((info (if (and attributes (floatp (car attributes)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
94 (list :version (car attributes))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
95 attributes)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
96 (remassq name packages-package-list)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
97 (setq packages-package-list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
98 (cons (cons name info) packages-package-list))))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
99
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
100 (defun package-require (name version)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
101 (let ((pkg (assq name packages-package-list)))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
102 (cond ((null pkg)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
103 (error "Package %s has not been loaded into this XEmacsen"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
104 name))
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
105 ((< (package-get-key name :version) version)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
106 (error "Need version %g of package %s, got version %g"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
107 version name (cdr pkg)))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
108 (t t))))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
109
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
110 ;;; Build time stuff
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
111
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112 (defvar autoload-file-name "auto-autoloads.el"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 "Filename that autoloads are expected to be found in.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (defvar packages-hardcoded-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 '(
253
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 247
diff changeset
117 #+infodock "id-vers"
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 247
diff changeset
118 #+infodock "easymenu-id-xemacs"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 "Lisp packages that are always dumped with XEmacs")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 (defvar packages-useful-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 '("bytecomp"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 "byte-optimize"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 "shadow"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 "cl-macs")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 "Lisp packages that need early byte compilation.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 (defvar packages-unbytecompiled-lisp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 '("paths.el"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
131 "dumped-lisp.el"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
132 "dumped-pkg-lisp.el"
261
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 253
diff changeset
133 "version.el"
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 253
diff changeset
134 "Installation.el")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 "Lisp packages that should not be byte compiled.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 ;; Copied from help.el, could possibly move it to here permanently.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 ;; Unlike the FSF version, our `locate-library' uses the `locate-file'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 ;; primitive, which should make it lightning-fast.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (defun locate-library (library &optional nosuffix path interactive-call)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 "Show the precise file name of Emacs library LIBRARY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 This command searches the directories in `load-path' like `M-x load-library'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 to find the file that `M-x load-library RET LIBRARY RET' would load.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 to the specified name LIBRARY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 If the optional third arg PATH is specified, that list of directories
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 is used instead of `load-path'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 (interactive (list (read-string "Locate library: ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 nil nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 (let ((result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 (locate-file
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 library
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 (or path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 (and (boundp 'find-file-hooks)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 (member 'crypt-find-file-hook find-file-hooks)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161 ;; Compression involved.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 (if nosuffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 ":.gz:.Z"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164 ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 ;; No compression.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 (if nosuffix
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 ""
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 ".elc:.el:")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 4)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 (and interactive-call
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 (if result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 (message "Library is file %s" result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 (message "No library %s in search path" library)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 (defun packages-add-suffix (str)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 (if (null (string-match "\\.el\\'" str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179 (concat str ".elc")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
182 (defun packages-list-autoloads-path ()
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 "List autoloads from precomputed load-path."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 (let ((path load-path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 autoloads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (while path
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 (if (file-exists-p (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 autoload-file-name))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 (setq autoloads (cons (concat (car path)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 autoload-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 autoloads)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 (setq path (cdr path)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 autoloads))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
195 (defun packages-list-autoloads ()
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 "List autoload files in (what will be) the normal lisp search path.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 This function is used during build to find where the global symbol files so
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 they can be perused for their useful information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 ;; Source directory may not be initialized yet.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 ;; (print (prin1-to-string load-path))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 (if (null source-directory)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
202 (setq source-directory (concat (car load-path) "./")))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
203 (let ((files (directory-files (file-name-as-directory source-directory)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
204 t ".*"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 file autolist)
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
206 ;; (print (prin1-to-string source-directory))
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
207 ;; (print (prin1-to-string files))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 (while (setq file (car-safe files))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 (if (and (file-directory-p file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 (file-exists-p (concat file "/" autoload-file-name)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 (setq autolist (cons (concat file "/" autoload-file-name)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 autolist)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 (setq files (cdr files)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 autolist))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
216 ;; The following function cannot be called from a bare temacs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
217 (defun packages-new-autoloads ()
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
218 "Return autoloads files that have been added or modified since XEmacs dump."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
219 (require 'loadhist)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
220 (let ((me (concat invocation-directory invocation-name))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
221 (path load-path)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
222 result dir)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
223 (while path
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
224 (setq dir (file-truename (car path)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
225 (let ((autoload-file (file-name-sans-extension (concat
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
226 dir
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
227 autoload-file-name))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
228 ;; Check for:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
229 ;; 1. An auto-autoload file that hasn't provided a feature (because
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
230 ;; it has been installed since XEmacs was dumped).
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
231 ;; 2. auto-autoload.el being newer than the executable
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
232 ;; 3. auto-autoload.elc being newer than the executable (the .el
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
233 ;; could be missing or compressed)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
234 (when (or (and (null (file-provides autoload-file))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
235 (or (file-exists-p (concat autoload-file ".elc"))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
236 (file-exists-p (concat autoload-file ".el"))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
237 (and (file-newer-than-file-p (concat autoload-file ".el") me)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
238 (setq autoload-file (concat autoload-file ".el")))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
239 (and (file-newer-than-file-p (concat autoload-file
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
240 ".elc")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
241 me)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
242 (setq autoload-file (concat autoload-file ".elc"))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
243 (push autoload-file result)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
244 (setq path (cdr path)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
245 result))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
246
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
247 ;; The following function cannot be called from a bare temacs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
248 (defun packages-reload-autoloads ()
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
249 "Reload new or updated auto-autoloads files.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
250 This is an extremely dangerous function to call after the user-init-files
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
251 is run. Don't call it or you'll be sorry."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
252 (let ((autoload-list (packages-new-autoloads)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
253 (while autoload-list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
254 (let* ((autoload-file (car autoload-list))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
255 (feature (car-safe (file-provides autoload-file))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
256 (when feature
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
257 ;; (message "(unload-feature %S)" feature)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
258 (unload-feature feature))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
259 (condition-case nil
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
260 (load autoload-file)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
261 (t nil)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
262 (setq autoload-list (cdr autoload-list)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
263
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
264 ;; The following function cannot be called from a bare temacs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
265 (defun packages-reload-dumped-lisp ()
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
266 "Reload new or updated dumped lisp files (with exceptions).
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
267 This is an extremely dangerous function to call at any time."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
268 ;; Nothing for the moment
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
269 nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents: 233
diff changeset
270
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 ;; Data-directory is really a list now. Provide something to search it for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 ;; directories.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 (defun locate-data-directory (name &optional dir-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275 "Locate a directory in a search path DIR-LIST (a list of directories).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 (unless dir-list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 (setq dir-list data-directory-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 (let (found found-dir)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 (while (and (null found-dir) dir-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281 (setq found (concat (car dir-list) name "/")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 found-dir (file-directory-p found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 (or found-dir
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 (setq found nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 (setq dir-list (cdr dir-list)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 found))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
288 ;; Data-directory is really a list now. Provide something to search it for
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
289 ;; files.
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
290
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
291 (defun locate-data-file (name &optional dir-list)
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
292 "Locate a file in a search path DIR-LIST (a list of directories).
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
293 If no DIR-LIST is supplied, it defaults to `data-directory-list'.
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
294 This function is basically a wrapper over `locate-file'."
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
295 (unless dir-list
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
296 (setq dir-list data-directory-list))
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 237
diff changeset
297 (locate-file name dir-list))
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
298
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
299 ;; Path setup
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
300
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
301 (defun packages-find-package-path (roots)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
302 "Construct the package path underneath installation roots ROOTS."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
303 (let ((envvar-value (getenv "EMACSPACKAGEPATH")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
304 (if envvar-value
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
305 (decode-path-internal envvar-value)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
306 (let ((site-base-directory (paths-find-site-directory roots "packages"))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
307 (version-base-directory (paths-find-version-directory roots "packages")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
308 (if (or site-base-directory version-base-directory)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
309 (let ((site-mule-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
310 (and (featurep 'mule)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
311 (paths-find-site-directory roots
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
312 "mule-packages")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
313 (version-mule-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
314 (and (featurep 'mule)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
315 (paths-find-version-directory roots
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
316 "mule-packages")))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
317 ;; There needs to be a cleverer way of doing this
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
318 (site-infodock-directory
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
319 (and (featurep 'infodock)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
320 (paths-find-site-directory roots
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
321 "infodock-packages")))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
322 (version-infodock-directory
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
323 (and (featurep 'infodock)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
324 (paths-find-version-directory roots
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
325 "infodock-packages"))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
326 (append '("~/.xemacs/")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
327 '(nil)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
328 (and version-infodock-directory
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
329 (null (string-equal version-infodock-directory
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
330 site-infodock-directory))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
331 (list version-infodock-directory))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
332 (and site-infodock-directory
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
333 (list site-infodock-directory))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
334 (and version-mule-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
335 (null (string-equal version-mule-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
336 site-mule-directory))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
337 (list version-mule-directory))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
338 (and site-mule-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
339 (list site-mule-directory))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
340 (and version-base-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
341 (null (string-equal version-base-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
342 site-base-directory))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
343 (list version-base-directory))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
344 (and site-base-directory
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
345 (list site-base-directory))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
346 configure-package-path)))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
347
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
348 (defvar packages-special-bases '("etc" "info" "lisp" "lib-src" "bin")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
349 "Special subdirectories of packages.")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
350
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
351 (defun packages-find-packages-in-directories (directories)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
352 "Find all packages underneath directories in DIRECTORIES."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
353 (paths-find-recursive-path directories
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
354 (append paths-version-control-bases
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
355 packages-special-bases)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
356
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
357 (defun packages-split-path (path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
358 "Split PATH at NIL, return pair with two components.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
359 The second component is shared with PATH."
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
360 (let ((reverse-tail '())
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
361 (rest path))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
362 (while (and rest (null (null (car rest))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
363 (setq reverse-tail (cons (car rest) reverse-tail))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
364 (setq rest (cdr rest)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
365 (if (null rest)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
366 (cons path nil)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
367 (cons (nreverse reverse-tail) (cdr rest)))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
368
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
369 (defun packages-find-packages (package-path &optional inhibit)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
370 "Search for all packages in PACKAGE-PATH.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
371 PACKAGE-PATH may distinguish (by NIL-separation) between early,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
372 late and last packages.
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
373 If INHIBIT is non-NIL, return empty paths.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
374 This returns (LIST EARLY-PACKAGES LATE-PACKAGES LAST-PACKAGES)."
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
375 (if inhibit
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
376 (list '() '() '())
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
377 ;; When in doubt, it's late
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
378 (let* ((stuff (packages-split-path package-path))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
379 (early (and (cdr stuff) (car stuff)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
380 (late+last (or (cdr stuff) (car stuff)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
381 (stuff (packages-split-path late+last))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
382 (late (car stuff))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
383 (last (cdr stuff)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
384 (list (packages-find-packages-in-directories early)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
385 (packages-find-packages-in-directories late)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
386 (packages-find-packages-in-directories last)))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
387
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
388 (defun packages-find-package-library-path (packages suffixes)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
389 "Construct a path into a component of the packages hierarchy.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
390 PACKAGES is a list of package directories.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
391 SUFFIXES is a list of names of package subdirectories to look for."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
392 (let ((directories
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
393 (apply
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
394 #'append
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
395 (mapcar #'(lambda (package)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
396 (mapcar #'(lambda (suffix)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
397 (concat package suffix))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
398 suffixes))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
399 packages))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
400 (paths-directories-which-exist directories)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
401
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
402 (defun packages-find-package-load-path (packages)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
403 "Construct the load-path component for packages.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
404 PACKAGES is a list of package directories."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
405 (paths-find-recursive-load-path
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
406 (packages-find-package-library-path packages '("lisp/"))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
407
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
408 (defun packages-find-package-exec-path (packages)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
409 (packages-find-package-library-path packages
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
410 (list (concat "bin/" system-configuration "/")
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
411 "lib-src/")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
412
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
413 (defun packages-find-package-info-path (packages)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
414 (packages-find-package-library-path packages '("info/")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
415
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
416 (defun packages-find-package-data-path (packages)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
417 (packages-find-package-library-path packages '("etc/")))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
418
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
419 ;; Loading package initialization files
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
420
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
421 (defun packages-load-package-lisps (package-load-path base)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
422 "Load all Lisp files of a certain name along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
423 BASE is the base name of the files."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
424 (mapc #'(lambda (dir)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
425 (let ((file-name (expand-file-name base dir)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
426 (if (file-exists-p file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
427 (condition-case error
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
428 (load file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
429 (error
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
430 (warn (format "Autoload error in: %s:\n\t%s"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
431 file-name
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
432 (with-output-to-string
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
433 (display-error error nil)))))))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
434 package-load-path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
435
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
436 (defun packages-load-package-auto-autoloads (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
437 "Load auto-autoload files along a load path."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
438 (packages-load-package-lisps package-load-path
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
439 (file-name-sans-extension autoload-file-name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
440
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
441 (defun packages-handle-package-dumped-lisps (handle package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
442 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
443 Call HANDLE on each file off definitions of PACKAGE-LISP there."
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
444 (mapc #'(lambda (dir)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
445 (let ((file-name (expand-file-name "dumped-lisp.el" dir)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
446 (if (file-exists-p file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
447 (let (package-lisp
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
448 ;; 20.4 packages could set this
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
449 preloaded-file-list)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
450 (load file-name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
451 ;; dumped-lisp.el could have set this ...
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
452 (if package-lisp
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
453 (mapc #'(lambda (base)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
454 (funcall handle base))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
455 package-lisp))))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
456 package-load-path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
457
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
458 (defun packages-load-package-dumped-lisps (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
459 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
460 Also load files off PACKAGE-LISP definitions there"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
461 (packages-handle-package-dumped-lisps #'load package-load-path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
462
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
463 (defun packages-collect-package-dumped-lisps (package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
464 "Load dumped-lisp.el files along a load path.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
465 Return list of files off PACKAGE-LISP definitions there"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
466 (let ((*files* '()))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
467 (packages-handle-package-dumped-lisps
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
468 #'(lambda (file)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
469 (setq *files* (cons file *files*)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
470 package-load-path)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 261
diff changeset
471 (reverse *files*)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 (provide 'packages)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
474
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
475 ;;; packages.el ends here