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
|
|
40 '("cl-defs"
|
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"
|
|
48 "advice")
|
|
49 "Lisp packages that need early byte compilation.")
|
|
50
|
|
51 (defvar packages-unbytecompiled-lisp
|
|
52 '("paths.el"
|
|
53 "version.el")
|
|
54 "Lisp packages that should not be byte compiled.")
|
|
55
|
|
56 ;; Copied from subr.el
|
177
|
57 (defmacro lambda (&rest cdr)
|
|
58 "Return a lambda expression.
|
|
59 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
|
|
60 self-quoting; the result of evaluating the lambda expression is the
|
|
61 expression itself. The lambda expression may then be treated as a
|
|
62 function, i.e., stored as the function value of a symbol, passed to
|
|
63 funcall or mapcar, etc.
|
|
64
|
|
65 ARGS should take the same form as an argument list for a `defun'.
|
|
66 DOCSTRING is an optional documentation string.
|
|
67 If present, it should describe how to call the function.
|
|
68 But documentation strings are usually not useful in nameless functions.
|
|
69 INTERACTIVE should be a call to the function `interactive', which see.
|
|
70 It may also be omitted.
|
|
71 BODY should be a list of lisp expressions."
|
|
72 ;; Note that this definition should not use backquotes; subr.el should not
|
|
73 ;; depend on backquote.el.
|
|
74 ;; #### - I don't see why. So long as backquote.el doesn't use anything
|
|
75 ;; from subr.el, there's no problem with using backquotes here. --Stig
|
|
76 ;;(list 'function (cons 'lambda cdr)))
|
|
77 ;; -slb, This has to run in a naked temacs. Enough is enough.
|
|
78 ;; `(function (lambda ,@cdr)))
|
|
79 (list 'function (cons 'lambda cdr)))
|
163
|
80
|
189
|
81
|
163
|
82 ;; Copied from help.el, could possibly move it to here permanently.
|
189
|
83 ;; Unlike the FSF version, our `locate-library' uses the `locate-file'
|
|
84 ;; primitive, which should make it lightning-fast.
|
163
|
85
|
|
86 (defun locate-library (library &optional nosuffix path interactive-call)
|
|
87 "Show the precise file name of Emacs library LIBRARY.
|
|
88 This command searches the directories in `load-path' like `M-x load-library'
|
|
89 to find the file that `M-x load-library RET LIBRARY RET' would load.
|
|
90 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
|
|
91 to the specified name LIBRARY.
|
|
92
|
|
93 If the optional third arg PATH is specified, that list of directories
|
|
94 is used instead of `load-path'."
|
|
95 (interactive (list (read-string "Locate library: ")
|
|
96 nil nil
|
|
97 t))
|
189
|
98 (let ((result
|
|
99 (locate-file
|
|
100 library
|
|
101 (or path load-path)
|
|
102 (if nosuffix
|
|
103 ""
|
|
104 (if (or (rassq 'jka-compr-handler file-name-handler-alist)
|
|
105 (and (boundp 'find-file-hooks)
|
|
106 (member 'crypt-find-file-hook find-file-hooks)))
|
|
107 ".elc:.el:"
|
|
108 ;; The complex expression evaluates to a relatively
|
|
109 ;; short string, so we do it at compile-time.
|
|
110 ;; Nope. This is run out of temacs and `eval-when-compile' is
|
|
111 ;; a void function. --sb
|
|
112 (mapconcat #'identity
|
|
113 (apply 'nconc
|
|
114 (mapcar (lambda (compelt)
|
|
115 (mapcar (lambda (baselt)
|
|
116 (concat baselt compelt))
|
|
117 '(".elc" ".el" "")))
|
|
118 '(".Z" ".gz" "")))
|
|
119 ":")))
|
|
120 4)))
|
163
|
121 (and interactive-call
|
189
|
122 (if result
|
|
123 (message "Library is file %s" result)
|
|
124 (message "No library %s in search path" library)))
|
163
|
125 result))
|
|
126
|
|
127 (defun packages-add-suffix (str)
|
|
128 (if (null (string-match "\\.el\\'" str))
|
|
129 (concat str ".elc")
|
|
130 str))
|
|
131
|
183
|
132 (defun list-autoloads-path ()
|
|
133 "List autoloads from precomputed load-path."
|
|
134 (let ((path load-path)
|
|
135 autoloads)
|
|
136 (while path
|
|
137 (if (file-exists-p (concat (car path)
|
187
|
138 autoload-file-name))
|
183
|
139 (setq autoloads (cons (concat (car path)
|
187
|
140 autoload-file-name)
|
183
|
141 autoloads)))
|
|
142 (setq path (cdr path)))
|
|
143 autoloads))
|
|
144
|
163
|
145 (defun list-autoloads ()
|
|
146 "List autoload files in (what will be) the normal lisp search path.
|
|
147 This function is used during build to find where the global symbol files so
|
|
148 they can be perused for their useful information."
|
|
149 ;; Source directory may not be initialized yet.
|
|
150 ;; (print (prin1-to-string load-path))
|
|
151 (if (null source-directory)
|
|
152 (setq source-directory (concat (car load-path) "/..")))
|
|
153 (let ((files (directory-files source-directory t ".*"))
|
|
154 file autolist)
|
|
155 (while (setq file (car-safe files))
|
|
156 (if (and (file-directory-p file)
|
|
157 (file-exists-p (concat file "/" autoload-file-name)))
|
|
158 (setq autolist (cons (concat file "/" autoload-file-name)
|
|
159 autolist)))
|
|
160 (setq files (cdr files)))
|
|
161 autolist))
|
|
162
|
177
|
163 ;; The following function is called from temacs
|
|
164 (defun packages-find-packages-1 (package path-only)
|
|
165 "Search the supplied directory for associated directories.
|
|
166 The top level is assumed to look like:
|
|
167 info/ Contain texinfo files for lisp installed in this hierarchy
|
|
168 etc/ Contain data files for lisp installled in this hiearchy
|
|
169 lisp/ Contain directories which either have straight lisp code
|
|
170 or are self-contained packages of their own."
|
|
171 ;; Info files
|
|
172 (if (and (null path-only) (file-directory-p (concat package "/info")))
|
|
173 (setq Info-default-directory-list
|
|
174 (cons (concat package "/info/") Info-default-directory-list)))
|
|
175 ;; Data files
|
|
176 (if (and (null path-only) (file-directory-p (concat package "/etc")))
|
|
177 (setq data-directory-list
|
|
178 (cons (concat package "/etc/") data-directory-list)))
|
|
179 ;; Lisp files
|
|
180 (if (file-directory-p (concat package "/lisp"))
|
|
181 (progn
|
187
|
182 ;; (print (concat "DIR: " package "/lisp/"))
|
185
|
183 (setq load-path (cons (concat package "/lisp/") load-path))
|
177
|
184 (let ((dirs (directory-files (concat package "/lisp/")
|
|
185 t "^[^-.]" nil 'dirs-only))
|
|
186 dir)
|
|
187 (while dirs
|
|
188 (setq dir (car dirs))
|
187
|
189 ;; (print (concat "DIR: " dir "/"))
|
185
|
190 (setq load-path (cons (concat dir "/") load-path))
|
177
|
191 (packages-find-packages-1 dir path-only)
|
|
192 (setq dirs (cdr dirs)))))))
|
|
193
|
|
194 ;; The following function is called from temacs
|
187
|
195 (defun packages-find-packages (pkg-path path-only &optional suppress-user)
|
177
|
196 "Search the supplied path for additional info/etc/lisp directories.
|
|
197 Lisp directories if configured prior to build time will have equivalent
|
187
|
198 status as bundled packages.
|
|
199 If the argument `path-only' is non-nil, only the `load-path' will be set,
|
|
200 otherwise data directories and info directories will be added.
|
|
201 If the optional argument `suppress-user' is non-nil, package directories
|
|
202 rooted in a user login directory (like ~/.xemacs) will not be searched.
|
|
203 This is used at dump time to suppress the builder's local environment."
|
|
204 (let ((path (reverse pkg-path))
|
177
|
205 dir)
|
|
206 (while path
|
|
207 (setq dir (car path))
|
179
|
208 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n"))
|
187
|
209 (if (null (and suppress-user
|
|
210 (string-match "^~" dir)))
|
|
211 (progn
|
|
212 ;; (print dir)
|
|
213 (packages-find-packages-1 (expand-file-name dir) path-only)))
|
177
|
214 (setq path (cdr path)))))
|
|
215
|
|
216 ;; Data-directory is really a list now. Provide something to search it for
|
|
217 ;; directories.
|
|
218
|
189
|
219 (defun locate-data-directory (name &optional dir-list)
|
|
220 "Locate a directory in a search path DIR-LIST (a list of directories).
|
|
221 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
|
|
222 (unless dir-list
|
|
223 (setq dir-list data-directory-list))
|
|
224 (let (found found-dir)
|
|
225 (while (and (null found-dir) dir-list)
|
|
226 (setq found (concat (car dir-list) name "/")
|
|
227 found-dir (file-directory-p found))
|
|
228 (or found-dir
|
|
229 (setq found nil))
|
|
230 (setq dir-list (cdr dir-list)))
|
177
|
231 found))
|
|
232
|
|
233 ;; If we are being loaded as part of being dumped, bootstrap the rest of the
|
|
234 ;; load-path for loaddefs.
|
|
235 (if (fboundp 'load-gc)
|
187
|
236 (packages-find-packages package-path t t))
|
177
|
237
|
163
|
238 (provide 'packages)
|
|
239
|
|
240 ;;; packages.el ends here
|