Mercurial > hg > xemacs-beta
comparison lisp/packages.el @ 209:41ff10fd062f r20-4b3
Import from CVS: tag r20-4b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:04:58 +0200 |
parents | |
children | 78f53ef88e17 |
comparison
equal
deleted
inserted
replaced
208:f427b8ec4379 | 209:41ff10fd062f |
---|---|
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, dumped | |
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 is dumped with XEmacs. | |
30 | |
31 ;; This file provides low level facilities for XEmacs startup -- | |
32 ;; particularly regarding the package setup. This code has to run in | |
33 ;; what we call "bare temacs" -- i.e. XEmacs without the usual Lisp | |
34 ;; environment. Pay special attention: | |
35 | |
36 ;; - not to use the `lambda' macro. Use #'(lambda ...) instead. | |
37 ;; (this goes for any package loaded before `subr.el'.) | |
38 ;; | |
39 ;; - not to use macros, because they are not yet available (and this | |
40 ;; file must be loadable uncompiled.) This rules out CL-style | |
41 ;; macros like `when', for instance. | |
42 ;; | |
43 ;; - not to use `defcustom'. If you must add user-customizable | |
44 ;; variables here, use `defvar', and add the variable to | |
45 ;; `cus-start.el'. | |
46 | |
47 ;; Because of all this, make sure that the stuff you put here really | |
48 ;; belongs here. | |
49 | |
50 | |
51 ;;; Code: | |
52 | |
53 (defvar autoload-file-name "auto-autoloads.el" | |
54 "Filename that autoloads are expected to be found in.") | |
55 | |
56 (defvar packages-hardcoded-lisp | |
57 '( | |
58 ;; "startup" | |
59 ) | |
60 "Lisp packages that are always dumped with XEmacs") | |
61 | |
62 (defvar packages-useful-lisp | |
63 '("bytecomp" | |
64 "byte-optimize" | |
65 "advice" | |
66 "shadow" | |
67 "cl-macs") | |
68 "Lisp packages that need early byte compilation.") | |
69 | |
70 (defvar packages-unbytecompiled-lisp | |
71 '("paths.el" | |
72 "version.el") | |
73 "Lisp packages that should not be byte compiled.") | |
74 | |
75 | |
76 ;; Copied from help.el, could possibly move it to here permanently. | |
77 ;; Unlike the FSF version, our `locate-library' uses the `locate-file' | |
78 ;; primitive, which should make it lightning-fast. | |
79 | |
80 (defun locate-library (library &optional nosuffix path interactive-call) | |
81 "Show the precise file name of Emacs library LIBRARY. | |
82 This command searches the directories in `load-path' like `M-x load-library' | |
83 to find the file that `M-x load-library RET LIBRARY RET' would load. | |
84 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | |
85 to the specified name LIBRARY. | |
86 | |
87 If the optional third arg PATH is specified, that list of directories | |
88 is used instead of `load-path'." | |
89 (interactive (list (read-string "Locate library: ") | |
90 nil nil | |
91 t)) | |
92 (let ((result | |
93 (locate-file | |
94 library | |
95 (or path load-path) | |
96 (cond ((or (rassq 'jka-compr-handler file-name-handler-alist) | |
97 (and (boundp 'find-file-hooks) | |
98 (member 'crypt-find-file-hook find-file-hooks))) | |
99 ;; Compression involved. | |
100 (if nosuffix | |
101 ":.gz:.Z" | |
102 ".elc:.elc.gz:elc.Z:.el:.el.gz:.el.Z::.gz:.Z")) | |
103 (t | |
104 ;; No compression. | |
105 (if nosuffix | |
106 "" | |
107 ".elc:.el:"))) | |
108 4))) | |
109 (and interactive-call | |
110 (if result | |
111 (message "Library is file %s" result) | |
112 (message "No library %s in search path" library))) | |
113 result)) | |
114 | |
115 (defun packages-add-suffix (str) | |
116 (if (null (string-match "\\.el\\'" str)) | |
117 (concat str ".elc") | |
118 str)) | |
119 | |
120 (defun list-autoloads-path () | |
121 "List autoloads from precomputed load-path." | |
122 (let ((path load-path) | |
123 autoloads) | |
124 (while path | |
125 (if (file-exists-p (concat (car path) | |
126 autoload-file-name)) | |
127 (setq autoloads (cons (concat (car path) | |
128 autoload-file-name) | |
129 autoloads))) | |
130 (setq path (cdr path))) | |
131 autoloads)) | |
132 | |
133 (defun list-autoloads () | |
134 "List autoload files in (what will be) the normal lisp search path. | |
135 This function is used during build to find where the global symbol files so | |
136 they can be perused for their useful information." | |
137 ;; Source directory may not be initialized yet. | |
138 ;; (print (prin1-to-string load-path)) | |
139 (if (null source-directory) | |
140 (setq source-directory (concat (car load-path) "/.."))) | |
141 (let ((files (directory-files source-directory t ".*")) | |
142 file autolist) | |
143 (while (setq file (car-safe files)) | |
144 (if (and (file-directory-p file) | |
145 (file-exists-p (concat file "/" autoload-file-name))) | |
146 (setq autolist (cons (concat file "/" autoload-file-name) | |
147 autolist))) | |
148 (setq files (cdr files))) | |
149 autolist)) | |
150 | |
151 ;; The following function is called from temacs | |
152 (defun packages-find-packages-1 (package path-only user-package) | |
153 "Search the supplied directory for associated directories. | |
154 The top level is assumed to look like: | |
155 info/ Contain texinfo files for lisp installed in this hierarchy | |
156 etc/ Contain data files for lisp installled in this hiearchy | |
157 lisp/ Contain directories which either have straight lisp code | |
158 or are self-contained packages of their own. | |
159 | |
160 This is an internal function. Do not call it after startup." | |
161 ;; Info files | |
162 (if (and (null path-only) (file-directory-p (concat package "/info"))) | |
163 (let ((dir (concat package "/info/"))) | |
164 (if (not (member dir Info-default-directory-list)) | |
165 (nconc Info-default-directory-list (list dir))))) | |
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 | |
173 ; (print (concat "DIR: " | |
174 ; (if user-package "[USER]" "") | |
175 ; package | |
176 ; "/lisp/")) | |
177 (setq load-path (cons (concat package "/lisp/") load-path)) | |
178 (if user-package | |
179 (condition-case nil | |
180 (load (concat package "/lisp/" | |
181 (file-name-sans-extension autoload-file-name))) | |
182 (t nil))) | |
183 (let ((dirs (directory-files (concat package "/lisp/") | |
184 t "^[^-.]" nil 'dirs-only)) | |
185 dir) | |
186 (while dirs | |
187 (setq dir (car dirs)) | |
188 ; (print (concat "DIR: " dir "/")) | |
189 (setq load-path (cons (concat dir "/") load-path)) | |
190 (if user-package | |
191 (condition-case nil | |
192 (progn | |
193 ; (print | |
194 ; (concat dir "/" | |
195 ; (file-name-sans-extension autoload-file-name))) | |
196 (load | |
197 (concat dir "/" | |
198 (file-name-sans-extension autoload-file-name)))) | |
199 (t nil))) | |
200 (packages-find-packages-1 dir path-only user-package) | |
201 (setq dirs (cdr dirs))))))) | |
202 | |
203 ;; The following function is called from temacs | |
204 (defun packages-find-packages (pkg-path path-only &optional suppress-user) | |
205 "Search the supplied path for additional info/etc/lisp directories. | |
206 Lisp directories if configured prior to build time will have equivalent | |
207 status as bundled packages. | |
208 If the argument `path-only' is non-nil, only the `load-path' will be set, | |
209 otherwise data directories and info directories will be added. | |
210 If the optional argument `suppress-user' is non-nil, package directories | |
211 rooted in a user login directory (like ~/.xemacs) will not be searched. | |
212 This is used at dump time to suppress the builder's local environment." | |
213 (let ((path (reverse pkg-path)) | |
214 dir) | |
215 (while path | |
216 (setq dir (car path)) | |
217 ;; (prin1 (concat "Find: " (expand-file-name dir) "\n")) | |
218 (if (null (and (or suppress-user inhibit-package-init) | |
219 (string-match "^~" dir))) | |
220 (progn | |
221 ;; (print dir) | |
222 (packages-find-packages-1 (expand-file-name dir) | |
223 path-only | |
224 (string-match "^~" dir)))) | |
225 (setq path (cdr path))))) | |
226 | |
227 ;; Data-directory is really a list now. Provide something to search it for | |
228 ;; directories. | |
229 | |
230 (defun locate-data-directory (name &optional dir-list) | |
231 "Locate a directory in a search path DIR-LIST (a list of directories). | |
232 If no DIR-LIST is supplied, it defaults to `data-directory-list'." | |
233 (unless dir-list | |
234 (setq dir-list data-directory-list)) | |
235 (let (found found-dir) | |
236 (while (and (null found-dir) dir-list) | |
237 (setq found (concat (car dir-list) name "/") | |
238 found-dir (file-directory-p found)) | |
239 (or found-dir | |
240 (setq found nil)) | |
241 (setq dir-list (cdr dir-list))) | |
242 found)) | |
243 | |
244 ;; If we are being loaded as part of being dumped, bootstrap the rest of the | |
245 ;; load-path for loaddefs. | |
246 (if (fboundp 'load-gc) | |
247 (packages-find-packages package-path t t)) | |
248 | |
249 (provide 'packages) | |
250 | |
251 ;;; packages.el ends here |