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.
|
|
115 (if (rassq 'jka-compr-handler file-name-handler-alist)
|
|
116 (apply 'nconc
|
|
117 (mapcar (lambda (compelt)
|
|
118 (mapcar (lambda (baselt)
|
|
119 (concat baselt compelt))
|
|
120 basic))
|
|
121 compressed))
|
|
122 basic)))))
|
|
123 (or path load-path)))
|
|
124 (and interactive-call
|
|
125 (if result
|
|
126 (message "Library is file %s" result)
|
|
127 (message "No library %s in search path" library)))
|
|
128 result))
|
|
129
|
|
130 (defun packages-add-suffix (str)
|
|
131 (if (null (string-match "\\.el\\'" str))
|
|
132 (concat str ".elc")
|
|
133 str))
|
|
134
|
|
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")))
|
|
163 (setq Info-default-directory-list
|
|
164 (cons (concat package "/info/") Info-default-directory-list)))
|
|
165 ;; Data files
|
|
166 (if (and (null path-only) (file-directory-p (concat package "/etc")))
|
|
167 (setq data-directory-list
|
|
168 (cons (concat package "/etc/") data-directory-list)))
|
|
169 ;; Lisp files
|
|
170 (if (file-directory-p (concat package "/lisp"))
|
|
171 (progn
|
|
172 (setq load-path (cons (concat package "/lisp/") load-path))
|
|
173 (let ((dirs (directory-files (concat package "/lisp/")
|
|
174 t "^[^-.]" nil 'dirs-only))
|
|
175 dir)
|
|
176 (while dirs
|
|
177 (setq dir (car dirs))
|
|
178 (setq load-path (cons dir load-path))
|
|
179 (packages-find-packages-1 dir path-only)
|
|
180 (setq dirs (cdr dirs)))))))
|
|
181
|
|
182 ;; The following function is called from temacs
|
|
183 (defun packages-find-packages (pkg-path path-only)
|
|
184 "Search the supplied path for additional info/etc/lisp directories.
|
|
185 Lisp directories if configured prior to build time will have equivalent
|
|
186 status as bundled packages."
|
|
187 (let ((path pkg-path)
|
|
188 dir)
|
|
189 (while path
|
|
190 (setq dir (car path))
|
|
191 (prin1 (concat "Find: " (expand-file-name dir) "\n"))
|
|
192 (packages-find-packages-1 (expand-file-name dir) path-only)
|
|
193 (setq path (cdr path)))))
|
|
194
|
|
195 ;; Data-directory is really a list now. Provide something to search it for
|
|
196 ;; directories.
|
|
197
|
|
198 (defun locate-data-directory (name &optional data-dir-list)
|
|
199 "Locate a directory in a search path."
|
|
200 (unless data-dir-list
|
|
201 (setq data-dir-list data-directory-list))
|
|
202 (let (dir found found-dir (dirs data-dir-list))
|
|
203 (while (and (null found-dir) dirs)
|
|
204 (setq dir (car dirs))
|
|
205 (setq found (concat dir name "/"))
|
|
206 (setq found-dir (file-directory-p found))
|
|
207 (setq dirs (cdr dirs)))
|
|
208 found))
|
|
209
|
|
210 ;; If we are being loaded as part of being dumped, bootstrap the rest of the
|
|
211 ;; load-path for loaddefs.
|
|
212 (if (fboundp 'load-gc)
|
|
213 (packages-find-packages package-path t))
|
|
214
|
163
|
215 (provide 'packages)
|
|
216
|
|
217 ;;; packages.el ends here
|