annotate lisp/packages.el @ 4372:ebb35ddea76a

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