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
|
|
81 ;; Copied from help.el, could possibly move it to here permanently.
|
|
82 ;; This is taken directly from Emacs 19.34.94.
|
|
83
|
|
84 (defun locate-library (library &optional nosuffix path interactive-call)
|
|
85 "Show the precise file name of Emacs library LIBRARY.
|
|
86 This command searches the directories in `load-path' like `M-x load-library'
|
|
87 to find the file that `M-x load-library RET LIBRARY RET' would load.
|
|
88 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
|
|
89 to the specified name LIBRARY.
|
|
90
|
|
91 If the optional third arg PATH is specified, that list of directories
|
|
92 is used instead of `load-path'."
|
|
93 (interactive (list (read-string "Locate library: ")
|
|
94 nil nil
|
|
95 t))
|
|
96 (let (result)
|
|
97 (catch 'answer
|
|
98 (mapcar
|
|
99 (lambda (dir)
|
|
100 (mapcar
|
|
101 (lambda (suf)
|
|
102 (let ((try (expand-file-name (concat library suf) dir)))
|
|
103 (and (file-readable-p try)
|
|
104 (null (file-directory-p try))
|
|
105 (progn
|
|
106 (setq result try)
|
|
107 (throw 'answer try)))))
|
|
108 (if nosuffix
|
|
109 '("")
|
|
110 (let ((basic '(".elc" ".el" ""))
|
|
111 (compressed '(".Z" ".gz" "")))
|
|
112 ;; If autocompression mode is on,
|
|
113 ;; consider all combinations of library suffixes
|
|
114 ;; and compression suffixes.
|
183
|
115 (if (or (rassq 'jka-compr-handler file-name-handler-alist)
|
|
116 (member 'crypt-find-file-hook find-file-hooks))
|
163
|
117 (apply 'nconc
|
|
118 (mapcar (lambda (compelt)
|
|
119 (mapcar (lambda (baselt)
|
|
120 (concat baselt compelt))
|
|
121 basic))
|
|
122 compressed))
|
|
123 basic)))))
|
|
124 (or path load-path)))
|
|
125 (and interactive-call
|
|
126 (if result
|
|
127 (message "Library is file %s" result)
|
|
128 (message "No library %s in search path" library)))
|
|
129 result))
|
|
130
|
|
131 (defun packages-add-suffix (str)
|
|
132 (if (null (string-match "\\.el\\'" str))
|
|
133 (concat str ".elc")
|
|
134 str))
|
|
135
|
183
|
136 (defun list-autoloads-path ()
|
|
137 "List autoloads from precomputed load-path."
|
|
138 (let ((path load-path)
|
|
139 autoloads)
|
|
140 (while path
|
|
141 (if (file-exists-p (concat (car path)
|
|
142 "/" autoload-file-name))
|
|
143 (setq autoloads (cons (concat (car path)
|
|
144 "/" autoload-file-name)
|
|
145 autoloads)))
|
|
146 (setq path (cdr path)))
|
|
147 autoloads))
|
|
148
|
163
|
149 (defun list-autoloads ()
|
|
150 "List autoload files in (what will be) the normal lisp search path.
|
|
151 This function is used during build to find where the global symbol files so
|
|
152 they can be perused for their useful information."
|
|
153 ;; Source directory may not be initialized yet.
|
|
154 ;; (print (prin1-to-string load-path))
|
|
155 (if (null source-directory)
|
|
156 (setq source-directory (concat (car load-path) "/..")))
|
|
157 (let ((files (directory-files source-directory t ".*"))
|
|
158 file autolist)
|
|
159 (while (setq file (car-safe files))
|
|
160 (if (and (file-directory-p file)
|
|
161 (file-exists-p (concat file "/" autoload-file-name)))
|
|
162 (setq autolist (cons (concat file "/" autoload-file-name)
|
|
163 autolist)))
|
|
164 (setq files (cdr files)))
|
|
165 autolist))
|
|
166
|
177
|
167 ;; The following function is called from temacs
|
|
168 (defun packages-find-packages-1 (package path-only)
|
|
169 "Search the supplied directory for associated directories.
|
|
170 The top level is assumed to look like:
|
|
171 info/ Contain texinfo files for lisp installed in this hierarchy
|
|
172 etc/ Contain data files for lisp installled in this hiearchy
|
|
173 lisp/ Contain directories which either have straight lisp code
|
|
174 or are self-contained packages of their own."
|
|
175 ;; Info files
|
|
176 (if (and (null path-only) (file-directory-p (concat package "/info")))
|
|
177 (setq Info-default-directory-list
|
|
178 (cons (concat package "/info/") Info-default-directory-list)))
|
|
179 ;; Data files
|
|
180 (if (and (null path-only) (file-directory-p (concat package "/etc")))
|
|
181 (setq data-directory-list
|
|
182 (cons (concat package "/etc/") data-directory-list)))
|
|
183 ;; Lisp files
|
|
184 (if (file-directory-p (concat package "/lisp"))
|
|
185 (progn
|
183
|
186 (setq load-path (cons (concat package "/lisp") load-path))
|
177
|
187 (let ((dirs (directory-files (concat package "/lisp/")
|
|
188 t "^[^-.]" nil 'dirs-only))
|
|
189 dir)
|
|
190 (while dirs
|
|
191 (setq dir (car dirs))
|
|
192 (setq load-path (cons dir load-path))
|
|
193 (packages-find-packages-1 dir path-only)
|
|
194 (setq dirs (cdr dirs)))))))
|
|
195
|
|
196 ;; The following function is called from temacs
|
|
197 (defun packages-find-packages (pkg-path path-only)
|
|
198 "Search the supplied path for additional info/etc/lisp directories.
|
|
199 Lisp directories if configured prior to build time will have equivalent
|
|
200 status as bundled packages."
|
|
201 (let ((path pkg-path)
|
|
202 dir)
|
|
203 (while path
|
|
204 (setq dir (car path))
|
179
|
205 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n"))
|
177
|
206 (packages-find-packages-1 (expand-file-name dir) path-only)
|
|
207 (setq path (cdr path)))))
|
|
208
|
|
209 ;; Data-directory is really a list now. Provide something to search it for
|
|
210 ;; directories.
|
|
211
|
|
212 (defun locate-data-directory (name &optional data-dir-list)
|
|
213 "Locate a directory in a search path."
|
|
214 (unless data-dir-list
|
|
215 (setq data-dir-list data-directory-list))
|
|
216 (let (dir found found-dir (dirs data-dir-list))
|
|
217 (while (and (null found-dir) dirs)
|
|
218 (setq dir (car dirs))
|
|
219 (setq found (concat dir name "/"))
|
|
220 (setq found-dir (file-directory-p found))
|
|
221 (setq dirs (cdr dirs)))
|
|
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)
|
|
227 (packages-find-packages package-path t))
|
|
228
|
163
|
229 (provide 'packages)
|
|
230
|
|
231 ;;; packages.el ends here
|