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