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