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:"
|
191
|
108 ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z"))
|
189
|
109 4)))
|
163
|
110 (and interactive-call
|
189
|
111 (if result
|
|
112 (message "Library is file %s" result)
|
|
113 (message "No library %s in search path" library)))
|
163
|
114 result))
|
|
115
|
|
116 (defun packages-add-suffix (str)
|
|
117 (if (null (string-match "\\.el\\'" str))
|
|
118 (concat str ".elc")
|
|
119 str))
|
|
120
|
183
|
121 (defun list-autoloads-path ()
|
|
122 "List autoloads from precomputed load-path."
|
|
123 (let ((path load-path)
|
|
124 autoloads)
|
|
125 (while path
|
|
126 (if (file-exists-p (concat (car path)
|
187
|
127 autoload-file-name))
|
183
|
128 (setq autoloads (cons (concat (car path)
|
187
|
129 autoload-file-name)
|
183
|
130 autoloads)))
|
|
131 (setq path (cdr path)))
|
|
132 autoloads))
|
|
133
|
163
|
134 (defun list-autoloads ()
|
|
135 "List autoload files in (what will be) the normal lisp search path.
|
|
136 This function is used during build to find where the global symbol files so
|
|
137 they can be perused for their useful information."
|
|
138 ;; Source directory may not be initialized yet.
|
|
139 ;; (print (prin1-to-string load-path))
|
|
140 (if (null source-directory)
|
|
141 (setq source-directory (concat (car load-path) "/..")))
|
|
142 (let ((files (directory-files source-directory t ".*"))
|
|
143 file autolist)
|
|
144 (while (setq file (car-safe files))
|
|
145 (if (and (file-directory-p file)
|
|
146 (file-exists-p (concat file "/" autoload-file-name)))
|
|
147 (setq autolist (cons (concat file "/" autoload-file-name)
|
|
148 autolist)))
|
|
149 (setq files (cdr files)))
|
|
150 autolist))
|
|
151
|
177
|
152 ;; The following function is called from temacs
|
|
153 (defun packages-find-packages-1 (package path-only)
|
|
154 "Search the supplied directory for associated directories.
|
|
155 The top level is assumed to look like:
|
|
156 info/ Contain texinfo files for lisp installed in this hierarchy
|
|
157 etc/ Contain data files for lisp installled in this hiearchy
|
|
158 lisp/ Contain directories which either have straight lisp code
|
|
159 or are self-contained packages of their own."
|
|
160 ;; Info files
|
|
161 (if (and (null path-only) (file-directory-p (concat package "/info")))
|
|
162 (setq Info-default-directory-list
|
|
163 (cons (concat package "/info/") Info-default-directory-list)))
|
|
164 ;; Data files
|
|
165 (if (and (null path-only) (file-directory-p (concat package "/etc")))
|
|
166 (setq data-directory-list
|
|
167 (cons (concat package "/etc/") data-directory-list)))
|
|
168 ;; Lisp files
|
|
169 (if (file-directory-p (concat package "/lisp"))
|
|
170 (progn
|
187
|
171 ;; (print (concat "DIR: " package "/lisp/"))
|
185
|
172 (setq load-path (cons (concat package "/lisp/") load-path))
|
177
|
173 (let ((dirs (directory-files (concat package "/lisp/")
|
|
174 t "^[^-.]" nil 'dirs-only))
|
|
175 dir)
|
|
176 (while dirs
|
|
177 (setq dir (car dirs))
|
187
|
178 ;; (print (concat "DIR: " dir "/"))
|
185
|
179 (setq load-path (cons (concat dir "/") load-path))
|
177
|
180 (packages-find-packages-1 dir path-only)
|
|
181 (setq dirs (cdr dirs)))))))
|
|
182
|
|
183 ;; The following function is called from temacs
|
187
|
184 (defun packages-find-packages (pkg-path path-only &optional suppress-user)
|
177
|
185 "Search the supplied path for additional info/etc/lisp directories.
|
|
186 Lisp directories if configured prior to build time will have equivalent
|
187
|
187 status as bundled packages.
|
|
188 If the argument `path-only' is non-nil, only the `load-path' will be set,
|
|
189 otherwise data directories and info directories will be added.
|
|
190 If the optional argument `suppress-user' is non-nil, package directories
|
|
191 rooted in a user login directory (like ~/.xemacs) will not be searched.
|
|
192 This is used at dump time to suppress the builder's local environment."
|
|
193 (let ((path (reverse pkg-path))
|
177
|
194 dir)
|
|
195 (while path
|
|
196 (setq dir (car path))
|
179
|
197 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n"))
|
187
|
198 (if (null (and suppress-user
|
|
199 (string-match "^~" dir)))
|
|
200 (progn
|
|
201 ;; (print dir)
|
|
202 (packages-find-packages-1 (expand-file-name dir) path-only)))
|
177
|
203 (setq path (cdr path)))))
|
|
204
|
|
205 ;; Data-directory is really a list now. Provide something to search it for
|
|
206 ;; directories.
|
|
207
|
189
|
208 (defun locate-data-directory (name &optional dir-list)
|
|
209 "Locate a directory in a search path DIR-LIST (a list of directories).
|
|
210 If no DIR-LIST is supplied, it defaults to `data-directory-list'."
|
|
211 (unless dir-list
|
|
212 (setq dir-list data-directory-list))
|
|
213 (let (found found-dir)
|
|
214 (while (and (null found-dir) dir-list)
|
|
215 (setq found (concat (car dir-list) name "/")
|
|
216 found-dir (file-directory-p found))
|
|
217 (or found-dir
|
|
218 (setq found nil))
|
|
219 (setq dir-list (cdr dir-list)))
|
177
|
220 found))
|
|
221
|
|
222 ;; If we are being loaded as part of being dumped, bootstrap the rest of the
|
|
223 ;; load-path for loaddefs.
|
|
224 (if (fboundp 'load-gc)
|
187
|
225 (packages-find-packages package-path t t))
|
177
|
226
|
163
|
227 (provide 'packages)
|
|
228
|
|
229 ;;; packages.el ends here
|