163
|
1 ;;; packages.el --- Low level support for XEmacs packages
|
|
2
|
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: Steven L Baur <steve@altair.xemacs.org>
|
|
6 ;; Keywords: internal, lisp
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
23 ;; 02111-1307, USA.
|
|
24
|
|
25 ;;; Synched up with: Not in FSF
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
29 ;; This file provides low level facilities for XEmacs startup. Special
|
|
30 ;; requirements apply to some of these functions because they can be called
|
|
31 ;; during build from temacs and much of the usual lisp environment may
|
|
32 ;; be missing.
|
|
33
|
|
34 ;;; Code:
|
|
35
|
|
36 (defvar autoload-file-name "auto-autoloads.el"
|
|
37 "Filename that autoloads are expected to be found in.")
|
|
38
|
|
39 (defvar packages-hardcoded-lisp
|
195
|
40 '(
|
171
|
41 ;; "startup"
|
163
|
42 )
|
|
43 "Lisp packages that are always dumped with XEmacs")
|
|
44
|
|
45 (defvar packages-useful-lisp
|
|
46 '("bytecomp"
|
|
47 "byte-optimize"
|
195
|
48 "advice"
|
|
49 "shadow")
|
163
|
50 "Lisp packages that need early byte compilation.")
|
|
51
|
|
52 (defvar packages-unbytecompiled-lisp
|
|
53 '("paths.el"
|
|
54 "version.el")
|
|
55 "Lisp packages that should not be byte compiled.")
|
|
56
|
|
57 ;; Copied from subr.el
|
177
|
58 (defmacro lambda (&rest cdr)
|
|
59 "Return a lambda expression.
|
|
60 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
|
|
61 self-quoting; the result of evaluating the lambda expression is the
|
|
62 expression itself. The lambda expression may then be treated as a
|
|
63 function, i.e., stored as the function value of a symbol, passed to
|
|
64 funcall or mapcar, etc.
|
|
65
|
|
66 ARGS should take the same form as an argument list for a `defun'.
|
|
67 DOCSTRING is an optional documentation string.
|
|
68 If present, it should describe how to call the function.
|
|
69 But documentation strings are usually not useful in nameless functions.
|
|
70 INTERACTIVE should be a call to the function `interactive', which see.
|
|
71 It may also be omitted.
|
|
72 BODY should be a list of lisp expressions."
|
|
73 ;; Note that this definition should not use backquotes; subr.el should not
|
|
74 ;; depend on backquote.el.
|
|
75 ;; #### - I don't see why. So long as backquote.el doesn't use anything
|
|
76 ;; from subr.el, there's no problem with using backquotes here. --Stig
|
|
77 ;;(list 'function (cons 'lambda cdr)))
|
|
78 ;; -slb, This has to run in a naked temacs. Enough is enough.
|
|
79 ;; `(function (lambda ,@cdr)))
|
|
80 (list 'function (cons 'lambda cdr)))
|
163
|
81
|
189
|
82
|
163
|
83 ;; Copied from help.el, could possibly move it to here permanently.
|
189
|
84 ;; Unlike the FSF version, our `locate-library' uses the `locate-file'
|
|
85 ;; primitive, which should make it lightning-fast.
|
163
|
86
|
|
87 (defun locate-library (library &optional nosuffix path interactive-call)
|
|
88 "Show the precise file name of Emacs library LIBRARY.
|
|
89 This command searches the directories in `load-path' like `M-x load-library'
|
|
90 to find the file that `M-x load-library RET LIBRARY RET' would load.
|
|
91 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
|
|
92 to the specified name LIBRARY.
|
|
93
|
|
94 If the optional third arg PATH is specified, that list of directories
|
|
95 is used instead of `load-path'."
|
|
96 (interactive (list (read-string "Locate library: ")
|
|
97 nil nil
|
|
98 t))
|
189
|
99 (let ((result
|
|
100 (locate-file
|
|
101 library
|
|
102 (or path load-path)
|
|
103 (if nosuffix
|
|
104 ""
|
|
105 (if (or (rassq 'jka-compr-handler file-name-handler-alist)
|
|
106 (and (boundp 'find-file-hooks)
|
|
107 (member 'crypt-find-file-hook find-file-hooks)))
|
|
108 ".elc:.el:"
|
191
|
109 ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z"))
|
189
|
110 4)))
|
163
|
111 (and interactive-call
|
189
|
112 (if result
|
|
113 (message "Library is file %s" result)
|
|
114 (message "No library %s in search path" library)))
|
163
|
115 result))
|
|
116
|
|
117 (defun packages-add-suffix (str)
|
|
118 (if (null (string-match "\\.el\\'" str))
|
|
119 (concat str ".elc")
|
|
120 str))
|
|
121
|
183
|
122 (defun list-autoloads-path ()
|
|
123 "List autoloads from precomputed load-path."
|
|
124 (let ((path load-path)
|
|
125 autoloads)
|
|
126 (while path
|
|
127 (if (file-exists-p (concat (car path)
|
187
|
128 autoload-file-name))
|
183
|
129 (setq autoloads (cons (concat (car path)
|
187
|
130 autoload-file-name)
|
183
|
131 autoloads)))
|
|
132 (setq path (cdr path)))
|
|
133 autoloads))
|
|
134
|
163
|
135 (defun list-autoloads ()
|
|
136 "List autoload files in (what will be) the normal lisp search path.
|
|
137 This function is used during build to find where the global symbol files so
|
|
138 they can be perused for their useful information."
|
|
139 ;; Source directory may not be initialized yet.
|
|
140 ;; (print (prin1-to-string load-path))
|
|
141 (if (null source-directory)
|
|
142 (setq source-directory (concat (car load-path) "/..")))
|
|
143 (let ((files (directory-files source-directory t ".*"))
|
|
144 file autolist)
|
|
145 (while (setq file (car-safe files))
|
|
146 (if (and (file-directory-p file)
|
|
147 (file-exists-p (concat file "/" autoload-file-name)))
|
|
148 (setq autolist (cons (concat file "/" autoload-file-name)
|
|
149 autolist)))
|
|
150 (setq files (cdr files)))
|
|
151 autolist))
|
|
152
|
177
|
153 ;; The following function is called from temacs
|
|
154 (defun packages-find-packages-1 (package path-only)
|
|
155 "Search the supplied directory for associated directories.
|
|
156 The top level is assumed to look like:
|
|
157 info/ Contain texinfo files for lisp installed in this hierarchy
|
|
158 etc/ Contain data files for lisp installled in this hiearchy
|
|
159 lisp/ Contain directories which either have straight lisp code
|
|
160 or are self-contained packages of their own."
|
|
161 ;; Info files
|
|
162 (if (and (null path-only) (file-directory-p (concat package "/info")))
|
203
|
163 (let ((dir (concat package "/info/")))
|
|
164 (when (not (member dir Info-default-directory-list))
|
|
165 (nconc Info-default-directory-list (list dir)))))
|
177
|
166 ;; Data files
|
|
167 (if (and (null path-only) (file-directory-p (concat package "/etc")))
|
|
168 (setq data-directory-list
|
|
169 (cons (concat package "/etc/") data-directory-list)))
|
|
170 ;; Lisp files
|
|
171 (if (file-directory-p (concat package "/lisp"))
|
|
172 (progn
|
187
|
173 ;; (print (concat "DIR: " package "/lisp/"))
|
185
|
174 (setq load-path (cons (concat package "/lisp/") load-path))
|
177
|
175 (let ((dirs (directory-files (concat package "/lisp/")
|
|
176 t "^[^-.]" nil 'dirs-only))
|
|
177 dir)
|
|
178 (while dirs
|
|
179 (setq dir (car dirs))
|
187
|
180 ;; (print (concat "DIR: " dir "/"))
|
185
|
181 (setq load-path (cons (concat dir "/") load-path))
|
177
|
182 (packages-find-packages-1 dir path-only)
|
|
183 (setq dirs (cdr dirs)))))))
|
|
184
|
|
185 ;; The following function is called from temacs
|
187
|
186 (defun packages-find-packages (pkg-path path-only &optional suppress-user)
|
177
|
187 "Search the supplied path for additional info/etc/lisp directories.
|
|
188 Lisp directories if configured prior to build time will have equivalent
|
187
|
189 status as bundled packages.
|
|
190 If the argument `path-only' is non-nil, only the `load-path' will be set,
|
|
191 otherwise data directories and info directories will be added.
|
|
192 If the optional argument `suppress-user' is non-nil, package directories
|
|
193 rooted in a user login directory (like ~/.xemacs) will not be searched.
|
|
194 This is used at dump time to suppress the builder's local environment."
|
|
195 (let ((path (reverse pkg-path))
|
177
|
196 dir)
|
|
197 (while path
|
|
198 (setq dir (car path))
|
179
|
199 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n"))
|
187
|
200 (if (null (and suppress-user
|
|
201 (string-match "^~" dir)))
|
|
202 (progn
|
|
203 ;; (print dir)
|
|
204 (packages-find-packages-1 (expand-file-name dir) path-only)))
|
177
|
205 (setq path (cdr path)))))
|
|
206
|
|
207 ;; Data-directory is really a list now. Provide something to search it for
|
|
208 ;; directories.
|
|
209
|
189
|
210 (defun locate-data-directory (name &optional dir-list)
|
|
211 "Locate a directory in a search path DIR-LIST (a list of directories).
|
|
212 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
|
|
213 (unless dir-list
|
|
214 (setq dir-list data-directory-list))
|
|
215 (let (found found-dir)
|
|
216 (while (and (null found-dir) dir-list)
|
|
217 (setq found (concat (car dir-list) name "/")
|
|
218 found-dir (file-directory-p found))
|
|
219 (or found-dir
|
|
220 (setq found nil))
|
|
221 (setq dir-list (cdr dir-list)))
|
177
|
222 found))
|
|
223
|
|
224 ;; If we are being loaded as part of being dumped, bootstrap the rest of the
|
|
225 ;; load-path for loaddefs.
|
|
226 (if (fboundp 'load-gc)
|
187
|
227 (packages-find-packages package-path t t))
|
177
|
228
|
163
|
229 (provide 'packages)
|
|
230
|
|
231 ;;; packages.el ends here
|