Mercurial > hg > xemacs-beta
annotate lisp/packages.el @ 5407:7ba892d101ce
Convert remainder in "tests" with plain text GPLv2 to GPLv3
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Tue, 19 Oct 2010 22:33:36 +0200 |
parents | 308d34e9f07d |
children | b9167d522a9a |
rev | line source |
---|---|
428 | 1 ;;; packages.el --- Low level support for XEmacs packages |
2 | |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
2557 | 4 ;; Copyright (C) 2002, 2003, 2004 Ben Wing. |
428 | 5 |
6 ;; Author: Steven L Baur <steve@xemacs.org> | |
7 ;; Maintainer: Steven L Baur <steve@xemacs.org> | |
8 ;; Keywords: internal, lisp, dumped | |
9 | |
10 ;; This file is part of XEmacs. | |
11 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
12 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
13 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
14 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
15 ;; option) any later version. |
428 | 16 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
20 ;; for more details. |
428 | 21 |
22 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5264
diff
changeset
|
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 24 |
25 ;;; Synched up with: Not in FSF | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; This file is dumped with XEmacs. | |
30 | |
31 ;; This file provides low level facilities for XEmacs startup -- | |
32 ;; particularly regarding the package setup. This code has to run in | |
33 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp | |
34 ;; environment. Pay special attention: | |
35 | |
36 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead. | |
37 ;; (this goes for any package loaded before `subr.el'.) | |
38 ;; | |
39 ;; - not to use macros, because they are not yet available (and this | |
442 | 40 ;; file must be loadable uncompiled.) Built in macros, such as |
41 ;; `when' and `unless' are fine, of course. | |
428 | 42 ;; |
43 ;; - not to use `defcustom'. If you must add user-customizable | |
44 ;; variables here, use `defvar', and add the variable to | |
45 ;; `cus-start.el'. | |
46 | |
47 ;; Because of all this, make sure that the stuff you put here really | |
48 ;; belongs here. | |
49 | |
50 ;; This file requires find-paths.el. | |
51 | |
52 ;;; Code: | |
53 | |
54 ;;; Package versioning | |
55 | |
56 (defvar packages-package-list nil | |
454 | 57 "Database of installed packages and version numbers") |
428 | 58 |
2456 | 59 ;;; Directories and paths |
60 | |
61 ;;; Terminology: | |
62 | |
63 ;;; A *package hierarchy* is a directory that contains a collection of | |
64 ;;; packages; it has lisp/, info/, etc/ etc. subdirectories that | |
65 ;;; contain the files constituting the packages. | |
66 | |
67 ;;; A *package directory* contains package hierarchies---the package | |
68 ;;; hierarchies are typically in directories "xemacs-packages", | |
69 ;;; "mule-packages", and so on. A package hierarchy might only be | |
70 ;;; applicable for specific variants of XEmacs. | |
71 | |
72 ;;; Package hierarchies come in "early", "late", and "last" variants, | |
73 ;;; depending on their relative location in the various paths. | |
74 ;;; "Early" hierarchies are typically in the user's home directory, | |
75 ;;; "late" hierarchies are typically part of the XEmacs installation, | |
76 ;;; and "last" package hierarchies are for special purposes, such as | |
77 ;;; making the packages of some previous XEmacs version available. | |
428 | 78 |
79 (defvar packages-load-path-depth 1 | |
80 "Depth of load-path search in package hierarchies.") | |
81 | |
82 (defvar packages-data-path-depth 1 | |
83 "Depth of data-path search in package hierarchies.") | |
84 | |
2456 | 85 (defvar early-package-hierarchies nil |
86 "Package hierarchies early in the load path.") | |
428 | 87 |
88 (defvar early-package-load-path nil | |
89 "Load path for packages early in the load path.") | |
90 | |
2456 | 91 (defvar late-package-hierarchies nil |
92 "Package hierarchies late in the load path.") | |
428 | 93 |
94 (defvar late-package-load-path nil | |
95 "Load path for packages late in the load path.") | |
96 | |
2456 | 97 (defvar last-package-hierarchies nil |
98 "Package hierarchies last in the load path.") | |
428 | 99 |
100 (defvar last-package-load-path nil | |
101 "Load path for packages last in the load path.") | |
102 | |
2456 | 103 (defun packages-package-hierarchy-directory-names () |
104 "Returns a list package hierarchy directory names. | |
105 These are the valid immediate directory names of package | |
106 directories, directories with higher priority first" | |
4919
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
107 (delq nil `("site-packages" |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
108 ,(when (featurep 'mule) "mule-packages") |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
109 "xemacs-packages"))) |
428 | 110 |
111 (defun package-get-key-1 (info key) | |
112 "Locate keyword `key' in list." | |
113 (cond ((null info) | |
114 nil) | |
115 ((eq (car info) key) | |
116 (nth 1 info)) | |
117 (t (package-get-key-1 (cddr info) key)))) | |
118 | |
119 (defun package-get-key (name key) | |
120 "Get info `key' from package `name'." | |
121 (let ((info (assq name packages-package-list))) | |
122 (when info | |
123 (package-get-key-1 (cdr info) key)))) | |
124 | |
125 (defun package-provide (name &rest attributes) | |
126 (let ((info (if (and attributes (floatp (car attributes))) | |
127 (list :version (car attributes)) | |
128 attributes))) | |
129 (setq packages-package-list | |
130 (cons (cons name info) (remassq name packages-package-list))))) | |
131 | |
2557 | 132 (defun package-suppress (package file form) |
133 "Set up a package-suppress condition FORM for FILE in PACKAGE. | |
134 When XEmacs searches for a file in the load path, it will ignore FILE | |
135 if FORM evaluates to non-nil." | |
136 (setq load-suppress-alist | |
137 (acons (expand-file-name file load-file-name) form | |
138 load-suppress-alist))) | |
139 | |
428 | 140 (defun package-require (name version) |
141 (let ((pkg (assq name packages-package-list))) | |
142 (cond ((null pkg) | |
1410 | 143 (error 'invalid-state |
144 (format "Package %s has not been loaded into this XEmacsen" | |
145 name))) | |
428 | 146 ((< (package-get-key name :version) version) |
1410 | 147 (error 'search-failed |
148 (format "Need version %g of package %s, got version %g" | |
2252 | 149 version name (package-get-key name :version)))) |
428 | 150 (t t)))) |
151 | |
152 (defun package-delete-name (name) | |
153 (let (pkg) | |
154 ;; Delete ALL versions of package. | |
155 ;; This is pretty memory-intensive, as we use copy-alist when deleting | |
156 ;; package entries, to prevent side-effects in functions that call this | |
157 ;; one. | |
158 (while (setq pkg (assq name packages-package-list)) | |
159 (setq packages-package-list (delete pkg (copy-alist | |
1365 | 160 packages-package-list)))))) |
428 | 161 |
162 ;;; Build time stuff | |
163 | |
164 (defvar autoload-file-name "auto-autoloads.el" | |
165 "Filename that autoloads are expected to be found in.") | |
166 | |
1330 | 167 ;; Moved from help.el. |
428 | 168 ;; Unlike the FSF version, our `locate-library' uses the `locate-file' |
169 ;; primitive, which should make it lightning-fast. | |
170 | |
171 (defun locate-library (library &optional nosuffix path interactive-call) | |
172 "Show the precise file name of Emacs library LIBRARY. | |
173 This command searches the directories in `load-path' like `M-x load-library' | |
174 to find the file that `M-x load-library RET LIBRARY RET' would load. | |
175 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | |
176 to the specified name LIBRARY. | |
177 | |
178 If the optional third arg PATH is specified, that list of directories | |
179 is used instead of `load-path'." | |
624 | 180 (interactive (list (read-library-name "Locate library: ") |
428 | 181 nil nil |
182 t)) | |
183 (let ((result | |
184 (locate-file | |
185 library | |
186 (or path load-path) | |
187 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist) | |
188 (and (boundp 'find-file-hooks) | |
189 (member 'crypt-find-file-hook find-file-hooks))) | |
190 ;; Compression involved. | |
191 (if nosuffix | |
448 | 192 '("" ".gz" ".Z" ".bz2") |
193 '(".elc" ".elc.gz" "elc.Z" ".elc.bz2" | |
194 ".el" ".el.gz" ".el.Z" ".el.bz2" | |
195 "" ".gz" ".Z" ".bz2"))) | |
428 | 196 (t |
197 ;; No compression. | |
198 (if nosuffix | |
199 "" | |
200 '(".elc" ".el" ""))))))) | |
201 (and interactive-call | |
202 (if result | |
203 (message "Library is file %s" result) | |
204 (message "No library %s in search path" library))) | |
205 result)) | |
206 | |
207 (defun packages-add-suffix (str) | |
208 (if (null (string-match "\\.el\\'" str)) | |
209 (concat str ".elc") | |
210 str)) | |
211 | |
212 (defun packages-list-autoloads-path () | |
213 "List autoloads from precomputed load-path." | |
214 (let ((path load-path) | |
215 autoloads) | |
216 (while path | |
217 (if (file-exists-p (concat (car path) | |
218 autoload-file-name)) | |
219 (setq autoloads (cons (concat (car path) | |
220 autoload-file-name) | |
221 autoloads))) | |
222 (setq path (cdr path))) | |
223 autoloads)) | |
224 | |
225 (defun packages-list-autoloads (source-directory) | |
226 "List autoload files in (what will be) the normal lisp search path. | |
227 This function is used during build to find where the global symbol files so | |
228 they can be perused for their useful information." | |
229 (let ((files (directory-files (file-name-as-directory source-directory) | |
230 t ".*")) | |
231 file autolist) | |
232 ;; (print (prin1-to-string source-directory)) | |
233 ;; (print (prin1-to-string files)) | |
234 (while (setq file (car-safe files)) | |
235 (if (and (file-directory-p file) | |
236 (file-exists-p (concat (file-name-as-directory file) | |
237 autoload-file-name))) | |
238 (setq autolist (cons (concat (file-name-as-directory file) | |
239 autoload-file-name) | |
240 autolist))) | |
241 (setq files (cdr files))) | |
242 autolist)) | |
243 | |
244 ;; The following function cannot be called from a bare temacs | |
245 (defun packages-new-autoloads () | |
246 "Return autoloads files that have been added or modified since XEmacs dump." | |
247 (require 'loadhist) | |
248 (let ((me (concat invocation-directory invocation-name)) | |
249 (path load-path) | |
250 result dir) | |
251 (while path | |
252 (setq dir (file-truename (car path))) | |
253 (let ((autoload-file (file-name-sans-extension (concat | |
254 dir | |
255 autoload-file-name)))) | |
256 ;; Check for: | |
257 ;; 1. An auto-autoload file that hasn't provided a feature (because | |
258 ;; it has been installed since XEmacs was dumped). | |
259 ;; 2. auto-autoload.el being newer than the executable | |
260 ;; 3. auto-autoload.elc being newer than the executable (the .el | |
261 ;; could be missing or compressed) | |
262 (when (or (and (null (file-provides autoload-file)) | |
263 (or (file-exists-p (concat autoload-file ".elc")) | |
264 (file-exists-p (concat autoload-file ".el")))) | |
265 (and (file-newer-than-file-p (concat autoload-file ".el") me) | |
266 (setq autoload-file (concat autoload-file ".el"))) | |
267 (and (file-newer-than-file-p (concat autoload-file | |
268 ".elc") | |
269 me) | |
270 (setq autoload-file (concat autoload-file ".elc")))) | |
271 (push autoload-file result))) | |
272 (setq path (cdr path))) | |
273 result)) | |
274 | |
275 ;; The following function cannot be called from a bare temacs | |
276 (defun packages-reload-autoloads () | |
277 "Reload new or updated auto-autoloads files. | |
278 This is an extremely dangerous function to call after the user-init-files | |
279 is run. Don't call it or you'll be sorry." | |
280 (let ((autoload-list (packages-new-autoloads))) | |
281 (while autoload-list | |
282 (let* ((autoload-file (car autoload-list)) | |
283 (feature (car-safe (file-provides autoload-file)))) | |
284 (when feature | |
285 ;; (message "(unload-feature %S)" feature) | |
286 (unload-feature feature)) | |
287 (condition-case nil | |
288 (load autoload-file) | |
289 (t nil))) | |
290 (setq autoload-list (cdr autoload-list))))) | |
291 | |
292 ;; Data-directory is really a list now. Provide something to search it for | |
293 ;; directories. | |
294 | |
295 (defun locate-data-directory-list (name &optional dir-list) | |
296 "Locate the matching list of directories in a search path DIR-LIST. | |
297 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
298 (unless dir-list | |
299 (setq dir-list data-directory-list)) | |
300 (let (found found-dir found-dir-list) | |
301 (while dir-list | |
302 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
303 found-dir (file-directory-p found)) | |
304 (and found-dir | |
305 (setq found-dir-list (cons found found-dir-list))) | |
306 (setq dir-list (cdr dir-list))) | |
307 (nreverse found-dir-list))) | |
308 | |
309 ;; Data-directory is really a list now. Provide something to search it for | |
310 ;; a directory. | |
311 | |
312 (defun locate-data-directory (name &optional dir-list) | |
313 "Locate a directory in a search path DIR-LIST (a list of directories). | |
314 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
315 (unless dir-list | |
316 (setq dir-list data-directory-list)) | |
317 (let (found found-dir) | |
318 (while (and (null found-dir) dir-list) | |
319 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
320 found-dir (file-directory-p found)) | |
321 (or found-dir | |
322 (setq found nil)) | |
323 (setq dir-list (cdr dir-list))) | |
324 found)) | |
325 | |
326 ;; Data-directory is really a list now. Provide something to search it for | |
327 ;; files. | |
328 | |
329 (defun locate-data-file (name &optional dir-list) | |
330 "Locate a file in a search path DIR-LIST (a list of directories). | |
331 If no DIR-LIST is supplied, it defaults to `data-directory-list'. | |
332 This function is basically a wrapper over `locate-file'." | |
633 | 333 (locate-file name (or dir-list data-directory-list))) |
428 | 334 |
335 ;; Path setup | |
336 | |
2456 | 337 (defun packages-find-package-hierarchies-named (package-directories base) |
338 "Find a set of package hierarchies within an XEmacs installation. | |
339 PACKAGE-DIRECTORIES is a list of package directories. | |
340 BASE is a subdirectory name for the hierarchy. | |
341 Returns list of hierarchies." | |
342 (paths-directories-which-exist | |
343 (mapcar #'(lambda (package-directory) | |
3179 | 344 (file-name-as-directory |
345 (concat (file-name-as-directory package-directory) | |
346 base))) | |
2456 | 347 package-directories))) |
428 | 348 |
349 (defun packages-split-path (path) | |
350 "Split PATH at \"\", return pair with two components. | |
351 The second component is shared with PATH." | |
352 (let ((reverse-tail '()) | |
353 (rest path)) | |
354 (while (and rest (null (string-equal "" (car rest)))) | |
355 (setq reverse-tail (cons (car rest) reverse-tail)) | |
356 (setq rest (cdr rest))) | |
357 (if (null rest) | |
358 (cons path nil) | |
359 (cons (nreverse reverse-tail) (cdr rest))))) | |
360 | |
361 (defun packages-split-package-path (package-path) | |
362 "Split up PACKAGE-PATH into early, late and last components. | |
363 The separation is by \"\" components. | |
2456 | 364 This returns |
365 (LIST EARLY-PACKAGE-HIERARCHIES LATE-PACKAGE-HIERARCHIES LAST-PACKAGE-HIERARCHIES)." | |
428 | 366 ;; When in doubt, it's late |
367 (let* ((stuff (packages-split-path package-path)) | |
368 (early (and (cdr stuff) (car stuff))) | |
369 (late+last (or (cdr stuff) (car stuff))) | |
370 (stuff (packages-split-path late+last)) | |
371 (late (car stuff)) | |
372 (last (cdr stuff))) | |
2456 | 373 (list (mapcar #'file-name-as-directory early) |
374 (mapcar #'file-name-as-directory late) | |
375 (mapcar #'file-name-as-directory last)))) | |
428 | 376 |
377 (defun packages-deconstruct (list consumer) | |
2456 | 378 "Deconstruct LIST and feed it to CONSUMER. |
379 CONSUMER is a function that accepts the elements of LISTS as separate arguments." | |
428 | 380 (apply consumer list)) |
381 | |
2456 | 382 (defun packages-find-installation-package-directories (roots) |
383 "Find the package directories in the XEmacs installation. | |
384 ROOTS is a list of installation roots." | |
5003
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
385 (delete-duplicates |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
386 (nconc (paths-find-version-directories roots (list "") nil nil nil t) |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
387 (paths-find-site-directories roots (list "") nil)) |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
388 :test #'equal)) |
428 | 389 |
3179 | 390 (defun packages-find-package-hierarchies (package-directories &optional envvar default) |
2456 | 391 "Find package hierarchies in a list of package directories. |
392 PACKAGE-DIRECTORIES is a list of package directories. | |
3179 | 393 DEFAULT is a default list of package hierarchies. |
394 ENVVAR is the name of an environment variable that may override | |
395 the default." | |
396 (let* ((envvar-value (and envvar (getenv envvar))) | |
397 (package-directories | |
398 (if envvar-value | |
399 (split-path envvar-value) | |
400 package-directories))) | |
401 | |
402 (or (and (not envvar-value) default) | |
403 (let ((package-hierarchies '()) | |
404 (hierarchy-directories (packages-package-hierarchy-directory-names))) | |
405 (while hierarchy-directories | |
406 (setq package-hierarchies | |
407 (nconc package-hierarchies | |
408 (packages-find-package-hierarchies-named | |
409 package-directories | |
410 (car hierarchy-directories)))) | |
411 (setq hierarchy-directories (cdr hierarchy-directories))) | |
412 package-hierarchies)))) | |
2456 | 413 |
414 (defun packages-find-all-package-hierarchies (roots) | |
3179 | 415 "Find the package hierarchies. |
2456 | 416 ROOTS is a list of installation roots. |
417 Returns a list of three directory lists, the first being the list of early | |
418 hierarchies, the second that of the late hierarchies, and the third the | |
419 list of the last hierarchies." | |
3179 | 420 ;; EMACSPACKAGEPATH is a historical kludge |
428 | 421 (let ((envvar-value (getenv "EMACSPACKAGEPATH"))) |
3179 | 422 (cond |
423 (envvar-value | |
3184 | 424 (packages-deconstruct |
425 (packages-split-package-path (paths-decode-directory-path envvar-value)) | |
426 ;; we get package *directories* | |
427 #'(lambda (early late last) | |
428 (list | |
429 (packages-find-package-hierarchies early | |
430 "EMACSEARLYPACKAGES") | |
431 (packages-find-package-hierarchies late | |
432 "EMACSLATEPACKAGES") | |
433 (packages-find-package-hierarchies last | |
434 "EMACSLATEPACKAGES"))))) | |
435 ;; --with-package-path is also a historical kludge | |
3179 | 436 (configure-package-path |
428 | 437 (packages-deconstruct |
438 (packages-split-package-path configure-package-path) | |
3184 | 439 ;; we get package *hierarchies* |
3179 | 440 #'(lambda (early late last) |
2456 | 441 (list |
442 (packages-find-package-hierarchies (list user-init-directory) | |
3179 | 443 "EMACSEARLYPACKAGES" |
444 early) | |
2456 | 445 (packages-find-package-hierarchies (packages-find-installation-package-directories roots) |
3179 | 446 "EMACSLATEPACKAGES" |
447 | |
448 late) | |
2456 | 449 (packages-find-package-hierarchies '() |
3179 | 450 "EMACSLASTPACKAGES" |
451 last))))) | |
452 (t | |
453 (list | |
454 (packages-find-package-hierarchies (or configure-early-package-directories | |
455 (list user-init-directory)) | |
456 "EMACSEARLYPACKAGES") | |
457 (packages-find-package-hierarchies (or configure-late-package-directories | |
458 (packages-find-installation-package-directories roots)) | |
459 "EMACSLATEPACKAGES") | |
460 (packages-find-package-hierarchies configure-last-package-directories | |
461 "EMACSLASTPACKAGES")))))) | |
462 | |
2456 | 463 (defun packages-find-package-library-path (package-hierarchies suffixes) |
428 | 464 "Construct a path into a component of the packages hierarchy. |
2456 | 465 PACKAGE-HIERARCHIES is a list of package hierarchies. |
466 SUFFIXES is a list of names of hierarchy subdirectories to look for." | |
428 | 467 (let ((directories |
5264
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
468 (mapcan #'(lambda (hierarchy) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
469 (mapcar #'(lambda (suffix) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
470 (file-name-as-directory (concat hierarchy suffix))) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
471 suffixes)) |
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5228
diff
changeset
|
472 package-hierarchies))) |
428 | 473 (paths-directories-which-exist directories))) |
474 | |
2456 | 475 (defun packages-find-package-load-path (package-hierarchies) |
428 | 476 "Construct the load-path component for packages. |
2456 | 477 PACKAGE-HIERARCHIES is a list of package hierarchies." |
428 | 478 (paths-find-recursive-load-path |
2456 | 479 (packages-find-package-library-path package-hierarchies |
428 | 480 '("lisp")) |
481 packages-load-path-depth)) | |
482 | |
2456 | 483 (defun packages-find-package-exec-path (package-hierarchies) |
428 | 484 "Construct the exec-path component for packages. |
2456 | 485 PACKAGE-HIERARCHIES is a list of package hierarchies." |
486 (packages-find-package-library-path package-hierarchies | |
428 | 487 (list (paths-construct-path |
488 (list "bin" system-configuration)) | |
489 "lib-src"))) | |
490 | |
2456 | 491 (defun packages-find-package-info-path (package-hierarchies) |
428 | 492 "Construct the info-path component for packages. |
2456 | 493 PACKAGE-HIERARCHIES is a list of package directories." |
494 (packages-find-package-library-path package-hierarchies '("info"))) | |
428 | 495 |
2456 | 496 (defun packages-find-package-data-path (package-hierarchies) |
428 | 497 "Construct the data-path component for packages. |
2456 | 498 PACKAGE-HIERARCHIES is a list of package hierachies." |
428 | 499 (paths-find-recursive-load-path |
2456 | 500 (packages-find-package-library-path package-hierarchies |
428 | 501 '("etc")) |
502 packages-data-path-depth)) | |
503 | |
504 ;; Loading package initialization files | |
505 | |
506 (defun packages-load-package-lisps (package-load-path base) | |
507 "Load all Lisp files of a certain name along a load path. | |
508 BASE is the base name of the files." | |
509 (mapcar #'(lambda (dir) | |
793 | 510 (let ((file-name (expand-file-name base dir))) |
511 (with-trapping-errors | |
512 :operation (format "Autoload %s" file-name) | |
513 :class 'packages | |
514 (load file-name t t)))) | |
515 package-load-path)) | |
428 | 516 |
517 (defun packages-load-package-auto-autoloads (package-load-path) | |
518 "Load auto-autoload files along a load path." | |
519 (packages-load-package-lisps package-load-path | |
520 (file-name-sans-extension autoload-file-name))) | |
521 | |
522 (defun packages-handle-package-dumped-lisps (handle package-load-path) | |
523 "Load dumped-lisp.el files along a load path. | |
524 Call HANDLE on each file off definitions of PACKAGE-LISP there." | |
525 (mapcar #'(lambda (dir) | |
526 (let ((file-name (expand-file-name "dumped-lisp.el" dir))) | |
527 (if (file-exists-p file-name) | |
528 (let (package-lisp | |
529 ;; 20.4 packages could set this | |
530 preloaded-file-list) | |
531 (load file-name) | |
532 ;; dumped-lisp.el could have set this ... | |
533 (if package-lisp | |
534 (mapcar #'(lambda (base) | |
535 (funcall handle base)) | |
536 package-lisp)))))) | |
537 package-load-path)) | |
538 | |
539 (defun packages-load-package-dumped-lisps (package-load-path) | |
540 "Load dumped-lisp.el files along a load path. | |
444 | 541 Also load files off PACKAGE-LISP definitions there." |
428 | 542 (packages-handle-package-dumped-lisps #'load package-load-path)) |
543 | |
544 (defun packages-collect-package-dumped-lisps (package-load-path) | |
545 "Load dumped-lisp.el files along a load path. | |
444 | 546 Return list of files off PACKAGE-LISP definitions there." |
428 | 547 (let ((*files* '())) |
548 (packages-handle-package-dumped-lisps | |
549 #'(lambda (file) | |
550 (setq *files* (cons file *files*))) | |
551 package-load-path) | |
552 (reverse *files*))) | |
553 | |
554 (provide 'packages) | |
555 | |
556 ;;; packages.el ends here |