Mercurial > hg > xemacs-beta
annotate lisp/packages.el @ 5287:cd167465bf69
More permission consistency.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Mon, 14 Jun 2010 15:03:08 +0900 |
parents | 5efbd1253905 |
children | 0d43872986b6 |
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 'mule) "mule-packages") |
9c6ea1581159
Remove a couple of XEmacs-specific duplicate functions, find-paths.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
4108
diff
changeset
|
111 "xemacs-packages"))) |
428 | 112 |
113 (defun package-get-key-1 (info key) | |
114 "Locate keyword `key' in list." | |
115 (cond ((null info) | |
116 nil) | |
117 ((eq (car info) key) | |
118 (nth 1 info)) | |
119 (t (package-get-key-1 (cddr info) key)))) | |
120 | |
121 (defun package-get-key (name key) | |
122 "Get info `key' from package `name'." | |
123 (let ((info (assq name packages-package-list))) | |
124 (when info | |
125 (package-get-key-1 (cdr info) key)))) | |
126 | |
127 (defun package-provide (name &rest attributes) | |
128 (let ((info (if (and attributes (floatp (car attributes))) | |
129 (list :version (car attributes)) | |
130 attributes))) | |
131 (setq packages-package-list | |
132 (cons (cons name info) (remassq name packages-package-list))))) | |
133 | |
2557 | 134 (defun package-suppress (package file form) |
135 "Set up a package-suppress condition FORM for FILE in PACKAGE. | |
136 When XEmacs searches for a file in the load path, it will ignore FILE | |
137 if FORM evaluates to non-nil." | |
138 (setq load-suppress-alist | |
139 (acons (expand-file-name file load-file-name) form | |
140 load-suppress-alist))) | |
141 | |
428 | 142 (defun package-require (name version) |
143 (let ((pkg (assq name packages-package-list))) | |
144 (cond ((null pkg) | |
1410 | 145 (error 'invalid-state |
146 (format "Package %s has not been loaded into this XEmacsen" | |
147 name))) | |
428 | 148 ((< (package-get-key name :version) version) |
1410 | 149 (error 'search-failed |
150 (format "Need version %g of package %s, got version %g" | |
2252 | 151 version name (package-get-key name :version)))) |
428 | 152 (t t)))) |
153 | |
154 (defun package-delete-name (name) | |
155 (let (pkg) | |
156 ;; Delete ALL versions of package. | |
157 ;; This is pretty memory-intensive, as we use copy-alist when deleting | |
158 ;; package entries, to prevent side-effects in functions that call this | |
159 ;; one. | |
160 (while (setq pkg (assq name packages-package-list)) | |
161 (setq packages-package-list (delete pkg (copy-alist | |
1365 | 162 packages-package-list)))))) |
428 | 163 |
164 ;;; Build time stuff | |
165 | |
166 (defvar autoload-file-name "auto-autoloads.el" | |
167 "Filename that autoloads are expected to be found in.") | |
168 | |
1330 | 169 ;; Moved from help.el. |
428 | 170 ;; Unlike the FSF version, our `locate-library' uses the `locate-file' |
171 ;; primitive, which should make it lightning-fast. | |
172 | |
173 (defun locate-library (library &optional nosuffix path interactive-call) | |
174 "Show the precise file name of Emacs library LIBRARY. | |
175 This command searches the directories in `load-path' like `M-x load-library' | |
176 to find the file that `M-x load-library RET LIBRARY RET' would load. | |
177 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | |
178 to the specified name LIBRARY. | |
179 | |
180 If the optional third arg PATH is specified, that list of directories | |
181 is used instead of `load-path'." | |
624 | 182 (interactive (list (read-library-name "Locate library: ") |
428 | 183 nil nil |
184 t)) | |
185 (let ((result | |
186 (locate-file | |
187 library | |
188 (or path load-path) | |
189 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist) | |
190 (and (boundp 'find-file-hooks) | |
191 (member 'crypt-find-file-hook find-file-hooks))) | |
192 ;; Compression involved. | |
193 (if nosuffix | |
448 | 194 '("" ".gz" ".Z" ".bz2") |
195 '(".elc" ".elc.gz" "elc.Z" ".elc.bz2" | |
196 ".el" ".el.gz" ".el.Z" ".el.bz2" | |
197 "" ".gz" ".Z" ".bz2"))) | |
428 | 198 (t |
199 ;; No compression. | |
200 (if nosuffix | |
201 "" | |
202 '(".elc" ".el" ""))))))) | |
203 (and interactive-call | |
204 (if result | |
205 (message "Library is file %s" result) | |
206 (message "No library %s in search path" library))) | |
207 result)) | |
208 | |
209 (defun packages-add-suffix (str) | |
210 (if (null (string-match "\\.el\\'" str)) | |
211 (concat str ".elc") | |
212 str)) | |
213 | |
214 (defun packages-list-autoloads-path () | |
215 "List autoloads from precomputed load-path." | |
216 (let ((path load-path) | |
217 autoloads) | |
218 (while path | |
219 (if (file-exists-p (concat (car path) | |
220 autoload-file-name)) | |
221 (setq autoloads (cons (concat (car path) | |
222 autoload-file-name) | |
223 autoloads))) | |
224 (setq path (cdr path))) | |
225 autoloads)) | |
226 | |
227 (defun packages-list-autoloads (source-directory) | |
228 "List autoload files in (what will be) the normal lisp search path. | |
229 This function is used during build to find where the global symbol files so | |
230 they can be perused for their useful information." | |
231 (let ((files (directory-files (file-name-as-directory source-directory) | |
232 t ".*")) | |
233 file autolist) | |
234 ;; (print (prin1-to-string source-directory)) | |
235 ;; (print (prin1-to-string files)) | |
236 (while (setq file (car-safe files)) | |
237 (if (and (file-directory-p file) | |
238 (file-exists-p (concat (file-name-as-directory file) | |
239 autoload-file-name))) | |
240 (setq autolist (cons (concat (file-name-as-directory file) | |
241 autoload-file-name) | |
242 autolist))) | |
243 (setq files (cdr files))) | |
244 autolist)) | |
245 | |
246 ;; The following function cannot be called from a bare temacs | |
247 (defun packages-new-autoloads () | |
248 "Return autoloads files that have been added or modified since XEmacs dump." | |
249 (require 'loadhist) | |
250 (let ((me (concat invocation-directory invocation-name)) | |
251 (path load-path) | |
252 result dir) | |
253 (while path | |
254 (setq dir (file-truename (car path))) | |
255 (let ((autoload-file (file-name-sans-extension (concat | |
256 dir | |
257 autoload-file-name)))) | |
258 ;; Check for: | |
259 ;; 1. An auto-autoload file that hasn't provided a feature (because | |
260 ;; it has been installed since XEmacs was dumped). | |
261 ;; 2. auto-autoload.el being newer than the executable | |
262 ;; 3. auto-autoload.elc being newer than the executable (the .el | |
263 ;; could be missing or compressed) | |
264 (when (or (and (null (file-provides autoload-file)) | |
265 (or (file-exists-p (concat autoload-file ".elc")) | |
266 (file-exists-p (concat autoload-file ".el")))) | |
267 (and (file-newer-than-file-p (concat autoload-file ".el") me) | |
268 (setq autoload-file (concat autoload-file ".el"))) | |
269 (and (file-newer-than-file-p (concat autoload-file | |
270 ".elc") | |
271 me) | |
272 (setq autoload-file (concat autoload-file ".elc")))) | |
273 (push autoload-file result))) | |
274 (setq path (cdr path))) | |
275 result)) | |
276 | |
277 ;; The following function cannot be called from a bare temacs | |
278 (defun packages-reload-autoloads () | |
279 "Reload new or updated auto-autoloads files. | |
280 This is an extremely dangerous function to call after the user-init-files | |
281 is run. Don't call it or you'll be sorry." | |
282 (let ((autoload-list (packages-new-autoloads))) | |
283 (while autoload-list | |
284 (let* ((autoload-file (car autoload-list)) | |
285 (feature (car-safe (file-provides autoload-file)))) | |
286 (when feature | |
287 ;; (message "(unload-feature %S)" feature) | |
288 (unload-feature feature)) | |
289 (condition-case nil | |
290 (load autoload-file) | |
291 (t nil))) | |
292 (setq autoload-list (cdr autoload-list))))) | |
293 | |
294 ;; Data-directory is really a list now. Provide something to search it for | |
295 ;; directories. | |
296 | |
297 (defun locate-data-directory-list (name &optional dir-list) | |
298 "Locate the matching list of directories in a search path DIR-LIST. | |
299 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
300 (unless dir-list | |
301 (setq dir-list data-directory-list)) | |
302 (let (found found-dir found-dir-list) | |
303 (while dir-list | |
304 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
305 found-dir (file-directory-p found)) | |
306 (and found-dir | |
307 (setq found-dir-list (cons found found-dir-list))) | |
308 (setq dir-list (cdr dir-list))) | |
309 (nreverse found-dir-list))) | |
310 | |
311 ;; Data-directory is really a list now. Provide something to search it for | |
312 ;; a directory. | |
313 | |
314 (defun locate-data-directory (name &optional dir-list) | |
315 "Locate a directory in a search path DIR-LIST (a list of directories). | |
316 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
317 (unless dir-list | |
318 (setq dir-list data-directory-list)) | |
319 (let (found found-dir) | |
320 (while (and (null found-dir) dir-list) | |
321 (setq found (file-name-as-directory (concat (car dir-list) name)) | |
322 found-dir (file-directory-p found)) | |
323 (or found-dir | |
324 (setq found nil)) | |
325 (setq dir-list (cdr dir-list))) | |
326 found)) | |
327 | |
328 ;; Data-directory is really a list now. Provide something to search it for | |
329 ;; files. | |
330 | |
331 (defun locate-data-file (name &optional dir-list) | |
332 "Locate a file in a search path DIR-LIST (a list of directories). | |
333 If no DIR-LIST is supplied, it defaults to `data-directory-list'. | |
334 This function is basically a wrapper over `locate-file'." | |
633 | 335 (locate-file name (or dir-list data-directory-list))) |
428 | 336 |
337 ;; Path setup | |
338 | |
2456 | 339 (defun packages-find-package-hierarchies-named (package-directories base) |
340 "Find a set of package hierarchies within an XEmacs installation. | |
341 PACKAGE-DIRECTORIES is a list of package directories. | |
342 BASE is a subdirectory name for the hierarchy. | |
343 Returns list of hierarchies." | |
344 (paths-directories-which-exist | |
345 (mapcar #'(lambda (package-directory) | |
3179 | 346 (file-name-as-directory |
347 (concat (file-name-as-directory package-directory) | |
348 base))) | |
2456 | 349 package-directories))) |
428 | 350 |
351 (defun packages-split-path (path) | |
352 "Split PATH at \"\", return pair with two components. | |
353 The second component is shared with PATH." | |
354 (let ((reverse-tail '()) | |
355 (rest path)) | |
356 (while (and rest (null (string-equal "" (car rest)))) | |
357 (setq reverse-tail (cons (car rest) reverse-tail)) | |
358 (setq rest (cdr rest))) | |
359 (if (null rest) | |
360 (cons path nil) | |
361 (cons (nreverse reverse-tail) (cdr rest))))) | |
362 | |
363 (defun packages-split-package-path (package-path) | |
364 "Split up PACKAGE-PATH into early, late and last components. | |
365 The separation is by \"\" components. | |
2456 | 366 This returns |
367 (LIST EARLY-PACKAGE-HIERARCHIES LATE-PACKAGE-HIERARCHIES LAST-PACKAGE-HIERARCHIES)." | |
428 | 368 ;; When in doubt, it's late |
369 (let* ((stuff (packages-split-path package-path)) | |
370 (early (and (cdr stuff) (car stuff))) | |
371 (late+last (or (cdr stuff) (car stuff))) | |
372 (stuff (packages-split-path late+last)) | |
373 (late (car stuff)) | |
374 (last (cdr stuff))) | |
2456 | 375 (list (mapcar #'file-name-as-directory early) |
376 (mapcar #'file-name-as-directory late) | |
377 (mapcar #'file-name-as-directory last)))) | |
428 | 378 |
379 (defun packages-deconstruct (list consumer) | |
2456 | 380 "Deconstruct LIST and feed it to CONSUMER. |
381 CONSUMER is a function that accepts the elements of LISTS as separate arguments." | |
428 | 382 (apply consumer list)) |
383 | |
2456 | 384 (defun packages-find-installation-package-directories (roots) |
385 "Find the package directories in the XEmacs installation. | |
386 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
|
387 (delete-duplicates |
6b6b0f8ab749
#'union doesn't preserve relative order; use #'delete-duplicates instead.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4919
diff
changeset
|
388 (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
|
389 (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
|
390 :test #'equal)) |
428 | 391 |
3179 | 392 (defun packages-find-package-hierarchies (package-directories &optional envvar default) |
2456 | 393 "Find package hierarchies in a list of package directories. |
394 PACKAGE-DIRECTORIES is a list of package directories. | |
3179 | 395 DEFAULT is a default list of package hierarchies. |
396 ENVVAR is the name of an environment variable that may override | |
397 the default." | |
398 (let* ((envvar-value (and envvar (getenv envvar))) | |
399 (package-directories | |
400 (if envvar-value | |
401 (split-path envvar-value) | |
402 package-directories))) | |
403 | |
404 (or (and (not envvar-value) default) | |
405 (let ((package-hierarchies '()) | |
406 (hierarchy-directories (packages-package-hierarchy-directory-names))) | |
407 (while hierarchy-directories | |
408 (setq package-hierarchies | |
409 (nconc package-hierarchies | |
410 (packages-find-package-hierarchies-named | |
411 package-directories | |
412 (car hierarchy-directories)))) | |
413 (setq hierarchy-directories (cdr hierarchy-directories))) | |
414 package-hierarchies)))) | |
2456 | 415 |
416 (defun packages-find-all-package-hierarchies (roots) | |
3179 | 417 "Find the package hierarchies. |
2456 | 418 ROOTS is a list of installation roots. |
419 Returns a list of three directory lists, the first being the list of early | |
420 hierarchies, the second that of the late hierarchies, and the third the | |
421 list of the last hierarchies." | |
3179 | 422 ;; EMACSPACKAGEPATH is a historical kludge |
428 | 423 (let ((envvar-value (getenv "EMACSPACKAGEPATH"))) |
3179 | 424 (cond |
425 (envvar-value | |
3184 | 426 (packages-deconstruct |
427 (packages-split-package-path (paths-decode-directory-path envvar-value)) | |
428 ;; we get package *directories* | |
429 #'(lambda (early late last) | |
430 (list | |
431 (packages-find-package-hierarchies early | |
432 "EMACSEARLYPACKAGES") | |
433 (packages-find-package-hierarchies late | |
434 "EMACSLATEPACKAGES") | |
435 (packages-find-package-hierarchies last | |
436 "EMACSLATEPACKAGES"))))) | |
437 ;; --with-package-path is also a historical kludge | |
3179 | 438 (configure-package-path |
428 | 439 (packages-deconstruct |
440 (packages-split-package-path configure-package-path) | |
3184 | 441 ;; we get package *hierarchies* |
3179 | 442 #'(lambda (early late last) |
2456 | 443 (list |
444 (packages-find-package-hierarchies (list user-init-directory) | |
3179 | 445 "EMACSEARLYPACKAGES" |
446 early) | |
2456 | 447 (packages-find-package-hierarchies (packages-find-installation-package-directories roots) |
3179 | 448 "EMACSLATEPACKAGES" |
449 | |
450 late) | |
2456 | 451 (packages-find-package-hierarchies '() |
3179 | 452 "EMACSLASTPACKAGES" |
453 last))))) | |
454 (t | |
455 (list | |
456 (packages-find-package-hierarchies (or configure-early-package-directories | |
457 (list user-init-directory)) | |
458 "EMACSEARLYPACKAGES") | |
459 (packages-find-package-hierarchies (or configure-late-package-directories | |
460 (packages-find-installation-package-directories roots)) | |
461 "EMACSLATEPACKAGES") | |
462 (packages-find-package-hierarchies configure-last-package-directories | |
463 "EMACSLASTPACKAGES")))))) | |
464 | |
2456 | 465 (defun packages-find-package-library-path (package-hierarchies suffixes) |
428 | 466 "Construct a path into a component of the packages hierarchy. |
2456 | 467 PACKAGE-HIERARCHIES is a list of package hierarchies. |
468 SUFFIXES is a list of names of hierarchy subdirectories to look for." | |
428 | 469 (let ((directories |
470 (apply | |
471 #'nconc | |
2456 | 472 (mapcar #'(lambda (hierarchy) |
428 | 473 (mapcar #'(lambda (suffix) |
2456 | 474 (file-name-as-directory (concat hierarchy suffix))) |
428 | 475 suffixes)) |
2456 | 476 package-hierarchies)))) |
428 | 477 (paths-directories-which-exist directories))) |
478 | |
2456 | 479 (defun packages-find-package-load-path (package-hierarchies) |
428 | 480 "Construct the load-path component for packages. |
2456 | 481 PACKAGE-HIERARCHIES is a list of package hierarchies." |
428 | 482 (paths-find-recursive-load-path |
2456 | 483 (packages-find-package-library-path package-hierarchies |
428 | 484 '("lisp")) |
485 packages-load-path-depth)) | |
486 | |
2456 | 487 (defun packages-find-package-exec-path (package-hierarchies) |
428 | 488 "Construct the exec-path component for packages. |
2456 | 489 PACKAGE-HIERARCHIES is a list of package hierarchies." |
490 (packages-find-package-library-path package-hierarchies | |
428 | 491 (list (paths-construct-path |
492 (list "bin" system-configuration)) | |
493 "lib-src"))) | |
494 | |
2456 | 495 (defun packages-find-package-info-path (package-hierarchies) |
428 | 496 "Construct the info-path component for packages. |
2456 | 497 PACKAGE-HIERARCHIES is a list of package directories." |
498 (packages-find-package-library-path package-hierarchies '("info"))) | |
428 | 499 |
2456 | 500 (defun packages-find-package-data-path (package-hierarchies) |
428 | 501 "Construct the data-path component for packages. |
2456 | 502 PACKAGE-HIERARCHIES is a list of package hierachies." |
428 | 503 (paths-find-recursive-load-path |
2456 | 504 (packages-find-package-library-path package-hierarchies |
428 | 505 '("etc")) |
506 packages-data-path-depth)) | |
507 | |
508 ;; Loading package initialization files | |
509 | |
510 (defun packages-load-package-lisps (package-load-path base) | |
511 "Load all Lisp files of a certain name along a load path. | |
512 BASE is the base name of the files." | |
513 (mapcar #'(lambda (dir) | |
793 | 514 (let ((file-name (expand-file-name base dir))) |
515 (with-trapping-errors | |
516 :operation (format "Autoload %s" file-name) | |
517 :class 'packages | |
518 (load file-name t t)))) | |
519 package-load-path)) | |
428 | 520 |
521 (defun packages-load-package-auto-autoloads (package-load-path) | |
522 "Load auto-autoload files along a load path." | |
523 (packages-load-package-lisps package-load-path | |
524 (file-name-sans-extension autoload-file-name))) | |
525 | |
526 (defun packages-handle-package-dumped-lisps (handle package-load-path) | |
527 "Load dumped-lisp.el files along a load path. | |
528 Call HANDLE on each file off definitions of PACKAGE-LISP there." | |
529 (mapcar #'(lambda (dir) | |
530 (let ((file-name (expand-file-name "dumped-lisp.el" dir))) | |
531 (if (file-exists-p file-name) | |
532 (let (package-lisp | |
533 ;; 20.4 packages could set this | |
534 preloaded-file-list) | |
535 (load file-name) | |
536 ;; dumped-lisp.el could have set this ... | |
537 (if package-lisp | |
538 (mapcar #'(lambda (base) | |
539 (funcall handle base)) | |
540 package-lisp)))))) | |
541 package-load-path)) | |
542 | |
543 (defun packages-load-package-dumped-lisps (package-load-path) | |
544 "Load dumped-lisp.el files along a load path. | |
444 | 545 Also load files off PACKAGE-LISP definitions there." |
428 | 546 (packages-handle-package-dumped-lisps #'load package-load-path)) |
547 | |
548 (defun packages-collect-package-dumped-lisps (package-load-path) | |
549 "Load dumped-lisp.el files along a load path. | |
444 | 550 Return list of files off PACKAGE-LISP definitions there." |
428 | 551 (let ((*files* '())) |
552 (packages-handle-package-dumped-lisps | |
553 #'(lambda (file) | |
554 (setq *files* (cons file *files*))) | |
555 package-load-path) | |
556 (reverse *files*))) | |
557 | |
558 (provide 'packages) | |
559 | |
560 ;;; packages.el ends here |