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