428
|
1 ;; loadup.el --- load up standardly loaded Lisp files for XEmacs.
|
|
2
|
|
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1996 Richard Mlynarik.
|
1261
|
5 ;; Copyright (C) 1995, 1996, 2003 Ben Wing.
|
428
|
6
|
|
7 ;; Maintainer: XEmacs Development Team
|
|
8 ;; Keywords: internal, dumped
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
|
26
|
|
27 ;;; Synched up with: Last synched with FSF 19.30, with wild divergence since.
|
|
28
|
|
29 ;;; Commentary:
|
|
30
|
1261
|
31 ;; If you are wanting to add files to be dumped into your local version of
|
|
32 ;; XEmacs, DO NOT add them here. Use site-init.el or site-load.el instead.
|
428
|
33
|
|
34 ;; This is loaded into a bare XEmacs to make a dumpable one.
|
|
35
|
|
36 ;;; Code:
|
|
37
|
1261
|
38 ;; Help debug problems.
|
|
39 (setq stack-trace-on-error t
|
|
40 load-always-display-messages t)
|
|
41
|
1330
|
42 ;(princ (format "command-line-args: %s\n" command-line-args))
|
|
43 ;(princ (format "configure-lisp-directory: %S\n" configure-lisp-directory))
|
|
44 ;(princ (format "configure-data-directory: %S\n" configure-data-directory))
|
|
45 ;(princ (format "lisp-directory: %S\n" lisp-directory))
|
|
46
|
428
|
47 (when (fboundp 'error)
|
|
48 (error "loadup.el already loaded!"))
|
|
49
|
3511
|
50 (defconst running-xemacs t
|
428
|
51 "Non-nil when the current emacs is XEmacs.")
|
3511
|
52
|
|
53 ;; Can't make this constant for now because it causes an error in
|
|
54 ;; update-elc.el.
|
|
55 (defvar source-lisp (file-name-directory (expand-file-name
|
|
56 (nth 2 command-line-args)))
|
|
57 "Root of tree containing the Lisp source code for the current build.
|
|
58 Differs from `lisp-directory' if this XEmacs has been installed. ")
|
|
59
|
|
60 (defconst build-directory (expand-file-name ".." invocation-directory)
|
|
61 "Root of tree containing object files and executables produced by build.
|
|
62 Differs from `source-directory' if configured with --srcdir option, a practice
|
|
63 recommended for developers.")
|
|
64
|
|
65 (defconst source-directory (expand-file-name ".." source-lisp)
|
|
66 "Root of tree containing source code for the current build.
|
|
67 Used during loadup and for documenting source of symbols defined in C.")
|
|
68
|
428
|
69 (defvar preloaded-file-list nil
|
|
70 "List of files preloaded into the XEmacs binary image.")
|
|
71
|
|
72 (defvar Installation-string nil
|
|
73 "Description of XEmacs installation.")
|
|
74
|
442
|
75 ;(start-profiling)
|
|
76
|
|
77 (let ((gc-cons-threshold
|
|
78 ;; setting it low makes loadup incredibly fucking slow.
|
|
79 ;; no need to do it when not dumping.
|
|
80 (if (and purify-flag
|
|
81 (not (memq 'quick-build internal-error-checking)))
|
|
82 30000 3000000)))
|
1261
|
83
|
|
84 ;; really-early-error-handler outputs a stack trace so let's not do it
|
|
85 ;; twice.
|
|
86 (let ((stack-trace-on-error nil))
|
428
|
87
|
|
88 ;; This is awfully damn early to be getting an error, right?
|
|
89 (call-with-condition-handler 'really-early-error-handler
|
|
90 #'(lambda ()
|
|
91
|
440
|
92 ;; Initialize Installation-string. We do it before loading
|
428
|
93 ;; anything so that dumped code can make use of its value.
|
|
94 (setq Installation-string
|
|
95 (save-current-buffer
|
|
96 (set-buffer (get-buffer-create (generate-new-buffer-name
|
|
97 " *temp*")))
|
|
98 ;; insert-file-contents-internal bogusly calls
|
|
99 ;; format-decode without checking if it's defined.
|
|
100 (fset 'format-decode #'(lambda (f l &optional v) l))
|
1330
|
101 (insert-file-contents-internal
|
3511
|
102 (expand-file-name "Installation" build-directory))
|
428
|
103 (fmakunbound 'format-decode)
|
|
104 (prog1 (buffer-substring)
|
|
105 (kill-buffer (current-buffer)))))
|
|
106
|
1330
|
107 (setq load-path (list source-lisp))
|
3511
|
108 (setq module-load-path (list
|
|
109 (expand-file-name "modules" build-directory)))
|
428
|
110
|
|
111 ;; message not defined yet ...
|
|
112 (external-debugging-output (format "\nUsing load-path %s" load-path))
|
|
113 (external-debugging-output (format "\nUsing module-load-path %s"
|
|
114 module-load-path))
|
|
115
|
|
116 ;; We don't want to have any undo records in the dumped XEmacs.
|
|
117 (buffer-disable-undo (get-buffer "*scratch*"))
|
|
118
|
|
119 ;; lread.c (or src/Makefile.in.in) has prepended
|
|
120 ;; "${srcdir}/../lisp/" to load-path, which is how this file
|
|
121 ;; has been found. At this point, enough of XEmacs has been
|
|
122 ;; initialized that we can start dumping "standard" lisp.
|
|
123 ;; Dumped lisp from external packages is added when we search
|
|
124 ;; the package path.
|
|
125 ;; #### This code is duplicated in two other places.
|
|
126 (let ((temp-path (expand-file-name "." (car load-path))))
|
|
127 (setq load-path (nconc (mapcar
|
|
128 #'(lambda (i) (concat i "/"))
|
|
129 (directory-files temp-path t "^[^-.]"
|
|
130 nil 'dirs-only))
|
|
131 (cons (file-name-as-directory temp-path)
|
|
132 load-path))))
|
|
133
|
1261
|
134 (setq load-warn-when-source-only t) ; Set to nil at the end
|
428
|
135
|
|
136 ;; garbage collect after loading every file in an attempt to
|
|
137 ;; minimize the size of the dumped image (if we don't do this,
|
|
138 ;; there will be lots of extra space in the data segment filled
|
|
139 ;; with garbage-collected junk)
|
|
140 (defun pureload (file)
|
|
141 (let ((full-path
|
|
142 (locate-file file load-path
|
|
143 (if load-ignore-elc-files
|
|
144 '(".el" "") '(".elc" ".el" "")))))
|
|
145 (if full-path
|
|
146 (prog1
|
|
147 (load full-path)
|
442
|
148 ;; but garbage collection really slows down loading.
|
|
149 (unless (memq 'quick-build internal-error-checking)
|
|
150 (garbage-collect)))
|
428
|
151 (external-debugging-output (format "\nLoad file %s: not found\n"
|
|
152 file))
|
|
153 ;; Uncomment in case of trouble
|
2456
|
154 ;;(print (format "late-package-hierarchies: %S" late-package-hierarchies))
|
1227
|
155 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p)))
|
|
156 ;;(print (format "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p)))
|
428
|
157 nil)))
|
|
158
|
1330
|
159 (load (expand-file-name "dumped-lisp.el" source-lisp))
|
428
|
160
|
|
161 (let ((files preloaded-file-list)
|
|
162 file)
|
|
163 (while (setq file (car files))
|
|
164 (unless (pureload file)
|
|
165 (external-debugging-output "Fatal error during load, aborting")
|
|
166 (kill-emacs 1))
|
|
167 (setq files (cdr files)))
|
|
168 (when (not (featurep 'toolbar))
|
|
169 ;; else still define a few functions.
|
|
170 (defun toolbar-button-p (obj) "No toolbar support." nil)
|
|
171 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
|
|
172 (fmakunbound 'pureload))
|
|
173
|
|
174 (packages-load-package-dumped-lisps late-package-load-path)
|
|
175
|
|
176 )) ;; end of call-with-condition-handler
|
1261
|
177
|
|
178 ) ; (let ((stack-trace-on-error nil)))
|
428
|
179
|
|
180 ;; Fix up the preloaded file list
|
|
181 (setq preloaded-file-list (mapcar #'file-name-sans-extension
|
|
182 preloaded-file-list))
|
|
183
|
1261
|
184 (setq load-warn-when-source-only nil)
|
428
|
185
|
|
186 (setq debugger 'debug)
|
|
187
|
|
188 (when (member "no-site-file" command-line-args)
|
|
189 (setq site-start-file nil))
|
|
190
|
|
191 ;; If you want additional libraries to be preloaded and their
|
|
192 ;; doc strings kept in the DOC file rather than in core,
|
|
193 ;; you may load them with a "site-load.el" file.
|
|
194 ;; But you must also cause them to be scanned when the DOC file
|
1261
|
195 ;; is generated. For MS Windows, you must edit ../nt/xemacs.mak.
|
|
196 ;; For other systems, you must edit ../src/Makefile.in.in.
|
428
|
197 (when (load "site-load" t)
|
442
|
198 (garbage-collect)
|
|
199 )
|
428
|
200
|
|
201 ;;FSFmacs randomness
|
|
202 ;;(if (fboundp 'x-popup-menu)
|
|
203 ;; (precompute-menubar-bindings))
|
|
204 ;;; Turn on recording of which commands get rebound,
|
|
205 ;;; for the sake of the next call to precompute-menubar-bindings.
|
|
206 ;(setq define-key-rebound-commands nil)
|
|
207
|
|
208 ;; Note: all compiled Lisp files loaded above this point
|
|
209 ;; must be among the ones parsed by make-docfile
|
|
210 ;; to construct DOC. Any that are not processed
|
|
211 ;; for DOC will not have doc strings in the dumped XEmacs.
|
|
212
|
|
213 ;; Don't bother with these if we're running temacs, i.e. if we're
|
|
214 ;; just debugging don't waste time finding doc strings.
|
|
215
|
|
216 ;; purify-flag is nil if called from loadup-el.el.
|
|
217 (when purify-flag
|
|
218 (message "Finding pointers to doc strings...")
|
|
219 (Snarf-documentation "DOC")
|
|
220 (message "Finding pointers to doc strings...done")
|
|
221 (Verify-documentation))
|
|
222
|
|
223 ;; Note: You can cause additional libraries to be preloaded
|
|
224 ;; by writing a site-init.el that loads them.
|
|
225 ;; See also "site-load" above.
|
|
226 (when (stringp site-start-file)
|
|
227 (load "site-init" t))
|
|
228 (setq current-load-list nil)
|
|
229 (garbage-collect)
|
|
230
|
|
231 ;;; At this point, we're ready to resume undo recording for scratch.
|
|
232 (buffer-enable-undo "*scratch*")
|
|
233
|
1261
|
234 ) ;; (let ((gc-cons-threshold [frequent garbage collection when dumping])))
|
428
|
235
|
442
|
236 ;(stop-profiling)
|
|
237
|
428
|
238 ;; Dump into the name `xemacs' (only)
|
|
239 (when (member "dump" command-line-args)
|
|
240 (message "Dumping under the name xemacs")
|
|
241 ;; This is handled earlier in the build process.
|
|
242 ;; (condition-case () (delete-file "xemacs") (file-error nil))
|
|
243 (when (fboundp 'really-free)
|
|
244 (really-free))
|
1261
|
245 ;; Make sure we don't dump with debugging messages turned on.
|
|
246 (setq stack-trace-on-error nil
|
|
247 load-always-display-messages nil)
|
462
|
248 (dump-emacs
|
|
249 (cond
|
|
250 ((featurep 'infodock) "infodock")
|
|
251 ;; #### BILL!!!
|
|
252 ;; If we want to dump under a name other than `xemacs', do that here!
|
|
253 ;; ((featurep 'gtk) "xemacs-gtk")
|
|
254 (t "xemacs"))
|
|
255 "temacs")
|
428
|
256 (kill-emacs))
|
|
257
|
|
258 ;; Avoid error if user loads some more libraries now.
|
|
259 (setq purify-flag nil)
|
|
260
|
|
261 (when (member "run-temacs" command-line-args)
|
|
262 (message "\nBootstrapping from temacs...")
|
|
263 ;; Remove all args up to and including "run-temacs"
|
|
264 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
|
|
265 ;; run-emacs-from-temacs doesn't actually return anyway.
|
|
266 (kill-emacs))
|
|
267
|
|
268 ;; XEmacs change
|
|
269 ;; If you are using 'recompile', then you should have used -l loadup-el.el
|
|
270 ;; so that the .el files always get loaded (the .elc files may be out-of-
|
|
271 ;; date or bad).
|
|
272 (when (member "recompile" command-line-args)
|
|
273 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
|
|
274 (batch-byte-recompile-directory)
|
|
275 (kill-emacs))
|
|
276
|
|
277 ;; For machines with CANNOT_DUMP defined in config.h,
|
|
278 ;; this file must be loaded each time Emacs is run.
|
|
279 ;; So run the startup code now.
|
|
280
|
|
281 (when (not (fboundp 'dump-emacs))
|
|
282 ;; Avoid loading loadup.el a second time!
|
|
283 (setq command-line-args (cdr (cdr command-line-args)))
|
|
284 (eval top-level))
|
|
285
|
|
286 ;;; loadup.el ends here
|