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.
|
|
5 ;; Copyright (C) 1995, 1996 Ben Wing.
|
|
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
|
|
31 ;; Please do not edit this file. Use site-init.el or site-load.el instead.
|
|
32
|
|
33 ;; This is loaded into a bare XEmacs to make a dumpable one.
|
|
34
|
|
35 ;;; Code:
|
|
36
|
|
37 (when (fboundp 'error)
|
|
38 (error "loadup.el already loaded!"))
|
|
39
|
|
40 (defvar running-xemacs t
|
|
41 "Non-nil when the current emacs is XEmacs.")
|
|
42 (defvar preloaded-file-list nil
|
|
43 "List of files preloaded into the XEmacs binary image.")
|
|
44
|
|
45 (defvar Installation-string nil
|
|
46 "Description of XEmacs installation.")
|
|
47
|
442
|
48 ;(start-profiling)
|
|
49
|
|
50 (let ((gc-cons-threshold
|
|
51 ;; setting it low makes loadup incredibly fucking slow.
|
|
52 ;; no need to do it when not dumping.
|
|
53 (if (and purify-flag
|
|
54 (not (memq 'quick-build internal-error-checking)))
|
|
55 30000 3000000)))
|
428
|
56
|
|
57 ;; This is awfully damn early to be getting an error, right?
|
|
58 (call-with-condition-handler 'really-early-error-handler
|
|
59 #'(lambda ()
|
|
60
|
440
|
61 ;; Initialize Installation-string. We do it before loading
|
428
|
62 ;; anything so that dumped code can make use of its value.
|
|
63 (setq Installation-string
|
|
64 (save-current-buffer
|
|
65 (set-buffer (get-buffer-create (generate-new-buffer-name
|
|
66 " *temp*")))
|
|
67 ;; insert-file-contents-internal bogusly calls
|
|
68 ;; format-decode without checking if it's defined.
|
|
69 (fset 'format-decode #'(lambda (f l &optional v) l))
|
|
70 (insert-file-contents-internal "../Installation")
|
|
71 (fmakunbound 'format-decode)
|
|
72 (prog1 (buffer-substring)
|
|
73 (kill-buffer (current-buffer)))))
|
|
74
|
442
|
75 (let ((build-root (expand-file-name ".." invocation-directory)))
|
|
76 (setq load-path (list (expand-file-name "lisp" build-root)))
|
|
77 (setq module-load-path (list (expand-file-name "modules" build-root))))
|
428
|
78
|
|
79 ;; message not defined yet ...
|
|
80 (external-debugging-output (format "\nUsing load-path %s" load-path))
|
|
81 (external-debugging-output (format "\nUsing module-load-path %s"
|
|
82 module-load-path))
|
|
83
|
|
84 ;; We don't want to have any undo records in the dumped XEmacs.
|
|
85 (buffer-disable-undo (get-buffer "*scratch*"))
|
|
86
|
|
87 ;; Load our first bootstrap support
|
|
88 (load "very-early-lisp" nil t)
|
|
89
|
|
90 ;; lread.c (or src/Makefile.in.in) has prepended
|
|
91 ;; "${srcdir}/../lisp/" to load-path, which is how this file
|
|
92 ;; has been found. At this point, enough of XEmacs has been
|
|
93 ;; initialized that we can start dumping "standard" lisp.
|
|
94 ;; Dumped lisp from external packages is added when we search
|
|
95 ;; the package path.
|
|
96 ;; #### This code is duplicated in two other places.
|
|
97 (let ((temp-path (expand-file-name "." (car load-path))))
|
|
98 (setq load-path (nconc (mapcar
|
|
99 #'(lambda (i) (concat i "/"))
|
|
100 (directory-files temp-path t "^[^-.]"
|
|
101 nil 'dirs-only))
|
|
102 (cons (file-name-as-directory temp-path)
|
|
103 load-path))))
|
|
104
|
|
105 (setq load-warn-when-source-newer t ; Used to be set to nil at the end
|
|
106 load-warn-when-source-only t) ; Set to nil at the end
|
|
107
|
|
108 ;; garbage collect after loading every file in an attempt to
|
|
109 ;; minimize the size of the dumped image (if we don't do this,
|
|
110 ;; there will be lots of extra space in the data segment filled
|
|
111 ;; with garbage-collected junk)
|
|
112 (defun pureload (file)
|
|
113 (let ((full-path
|
|
114 (locate-file file load-path
|
|
115 (if load-ignore-elc-files
|
|
116 '(".el" "") '(".elc" ".el" "")))))
|
|
117 (if full-path
|
|
118 (prog1
|
|
119 (load full-path)
|
442
|
120 ;; but garbage collection really slows down loading.
|
|
121 (unless (memq 'quick-build internal-error-checking)
|
|
122 (garbage-collect)))
|
428
|
123 (external-debugging-output (format "\nLoad file %s: not found\n"
|
|
124 file))
|
|
125 ;; Uncomment in case of trouble
|
|
126 ;;(print (format "late-packages: %S" late-packages))
|
|
127 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name)))
|
|
128 nil)))
|
|
129
|
|
130 (load (expand-file-name "../lisp/dumped-lisp.el"))
|
|
131
|
|
132 (let ((files preloaded-file-list)
|
|
133 file)
|
|
134 (while (setq file (car files))
|
|
135 (unless (pureload file)
|
|
136 (external-debugging-output "Fatal error during load, aborting")
|
|
137 (kill-emacs 1))
|
|
138 (setq files (cdr files)))
|
|
139 (when (not (featurep 'toolbar))
|
|
140 ;; else still define a few functions.
|
|
141 (defun toolbar-button-p (obj) "No toolbar support." nil)
|
|
142 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
|
|
143 (fmakunbound 'pureload))
|
|
144
|
|
145 (packages-load-package-dumped-lisps late-package-load-path)
|
|
146
|
|
147 )) ;; end of call-with-condition-handler
|
|
148
|
|
149 ;; Fix up the preloaded file list
|
|
150 (setq preloaded-file-list (mapcar #'file-name-sans-extension
|
|
151 preloaded-file-list))
|
|
152
|
|
153 (setq load-warn-when-source-newer t ; set to t at top of file
|
|
154 load-warn-when-source-only nil)
|
|
155
|
|
156 (setq debugger 'debug)
|
|
157
|
|
158 (when (member "no-site-file" command-line-args)
|
|
159 (setq site-start-file nil))
|
|
160
|
|
161 ;; If you want additional libraries to be preloaded and their
|
|
162 ;; doc strings kept in the DOC file rather than in core,
|
|
163 ;; you may load them with a "site-load.el" file.
|
|
164 ;; But you must also cause them to be scanned when the DOC file
|
|
165 ;; is generated. For VMS, you must edit ../../vms/makedoc.com.
|
|
166 ;; For other systems, you must edit ../../src/Makefile.in.in.
|
|
167 (when (load "site-load" t)
|
442
|
168 (garbage-collect)
|
|
169 )
|
428
|
170
|
|
171 ;;FSFmacs randomness
|
|
172 ;;(if (fboundp 'x-popup-menu)
|
|
173 ;; (precompute-menubar-bindings))
|
|
174 ;;; Turn on recording of which commands get rebound,
|
|
175 ;;; for the sake of the next call to precompute-menubar-bindings.
|
|
176 ;(setq define-key-rebound-commands nil)
|
|
177
|
|
178 ;; Note: all compiled Lisp files loaded above this point
|
|
179 ;; must be among the ones parsed by make-docfile
|
|
180 ;; to construct DOC. Any that are not processed
|
|
181 ;; for DOC will not have doc strings in the dumped XEmacs.
|
|
182
|
|
183 ;; Don't bother with these if we're running temacs, i.e. if we're
|
|
184 ;; just debugging don't waste time finding doc strings.
|
|
185
|
|
186 ;; purify-flag is nil if called from loadup-el.el.
|
|
187 (when purify-flag
|
|
188 (message "Finding pointers to doc strings...")
|
|
189 (Snarf-documentation "DOC")
|
|
190 (message "Finding pointers to doc strings...done")
|
|
191 (Verify-documentation))
|
|
192
|
|
193 ;; Note: You can cause additional libraries to be preloaded
|
|
194 ;; by writing a site-init.el that loads them.
|
|
195 ;; See also "site-load" above.
|
|
196 (when (stringp site-start-file)
|
|
197 (load "site-init" t))
|
|
198 (setq current-load-list nil)
|
|
199 (garbage-collect)
|
|
200
|
|
201 ;;; At this point, we're ready to resume undo recording for scratch.
|
|
202 (buffer-enable-undo "*scratch*")
|
|
203
|
|
204 ) ;; frequent garbage collection
|
|
205
|
442
|
206 ;(stop-profiling)
|
|
207
|
|
208 ;; yuck! need to insert the function def here, and rewrite the dolist
|
|
209 ;; loop below.
|
|
210
|
|
211 ;(defun loadup-profile-results (&optional info stream)
|
|
212 ; "Print profiling info INFO to STREAM in a pretty format.
|
|
213 ;If INFO is omitted, the current profiling info is retrieved using
|
|
214 ; `get-profiling-info'.
|
|
215 ;If STREAM is omitted, either a *Profiling Results* buffer or standard
|
|
216 ; output are used, depending on whether the function was called
|
|
217 ; interactively or not."
|
|
218 ; (interactive)
|
|
219 ; (setq info (if info
|
|
220 ; (copy-alist info)
|
|
221 ; (get-profiling-info)))
|
|
222 ; (when (and (not stream)
|
|
223 ; (interactive-p))
|
|
224 ; (pop-to-buffer (get-buffer-create "*Profiling Results*"))
|
|
225 ; (erase-buffer))
|
|
226 ; (let ((standard-output (or stream (if (interactive-p)
|
|
227 ; (current-buffer)
|
|
228 ; standard-output)))
|
|
229 ; ;; Calculate the longest function
|
|
230 ; (maxfunlen (apply #'max
|
|
231 ; (length "Function Name")
|
|
232 ; (mapcar
|
|
233 ; (lambda (el)
|
|
234 ; ;; Functions longer than 50 characters (usually
|
|
235 ; ;; anonymous functions) don't qualify
|
|
236 ; (let ((l (length (format "%s" (car el)))))
|
|
237 ; (if (< l 50)
|
|
238 ; l 0)))
|
|
239 ; info))))
|
|
240 ; (princ (format "%-*s Ticks %%/Total Call Count\n"
|
|
241 ; maxfunlen "Function Name"))
|
|
242 ; (princ (make-string maxfunlen ?=))
|
|
243 ; (princ " ===== ======= ==========\n")
|
|
244 ; (let ((sum (float (apply #'+ (mapcar #'cdr info)))))
|
|
245 ; (let (entry
|
|
246 ; (entry-list (nreverse (sort info #'cdr-less-than-cdr))))
|
|
247 ; (while entry-list
|
|
248 ; (setq entry (car entry-list))
|
|
249 ; (princ (format "%-*s %-5d %-6.3f %s\n"
|
|
250 ; maxfunlen (car entry) (cdr entry)
|
|
251 ; (* 100 (/ (cdr entry) sum))
|
|
252 ; (or (gethash (car entry) call-count-profile-table)
|
|
253 ; "")))
|
|
254 ; (setq entry-list (cdr entry-list))))
|
|
255 ; (princ (make-string maxfunlen ?-))
|
|
256 ; (princ "---------------------------------\n")
|
|
257 ; (princ (format "%-*s %-5d %-6.2f\n" maxfunlen "Total" sum 100.0))
|
|
258 ; (princ (format "\n\nOne tick = %g ms\n"
|
|
259 ; (/ default-profiling-interval 1000.0)))
|
|
260 ; (and (boundp 'internal-error-checking)
|
|
261 ; internal-error-checking
|
|
262 ; (princ "
|
|
263 ;WARNING: Error checking is turned on in this XEmacs. This might make
|
|
264 ; the measurements very unreliable.\n"))))
|
|
265 ; (when (and (not stream)
|
|
266 ; (interactive-p))
|
|
267 ; (goto-char (point-min))))
|
|
268
|
|
269 ;(loadup-profile-results nil 'external-debugging-output)
|
|
270
|
428
|
271 ;; Dump into the name `xemacs' (only)
|
|
272 (when (member "dump" command-line-args)
|
|
273 (message "Dumping under the name xemacs")
|
|
274 ;; This is handled earlier in the build process.
|
|
275 ;; (condition-case () (delete-file "xemacs") (file-error nil))
|
|
276 (when (fboundp 'really-free)
|
|
277 (really-free))
|
462
|
278 (dump-emacs
|
|
279 (cond
|
|
280 ((featurep 'infodock) "infodock")
|
|
281 ;; #### BILL!!!
|
|
282 ;; If we want to dump under a name other than `xemacs', do that here!
|
|
283 ;; ((featurep 'gtk) "xemacs-gtk")
|
|
284 (t "xemacs"))
|
|
285 "temacs")
|
428
|
286 (kill-emacs))
|
|
287
|
|
288 ;; Avoid error if user loads some more libraries now.
|
|
289 (setq purify-flag nil)
|
|
290
|
|
291 (when (member "run-temacs" command-line-args)
|
|
292 (message "\nBootstrapping from temacs...")
|
|
293 ;; Remove all args up to and including "run-temacs"
|
|
294 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
|
|
295 ;; run-emacs-from-temacs doesn't actually return anyway.
|
|
296 (kill-emacs))
|
|
297
|
|
298 ;; XEmacs change
|
|
299 ;; If you are using 'recompile', then you should have used -l loadup-el.el
|
|
300 ;; so that the .el files always get loaded (the .elc files may be out-of-
|
|
301 ;; date or bad).
|
|
302 (when (member "recompile" command-line-args)
|
|
303 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
|
|
304 (batch-byte-recompile-directory)
|
|
305 (kill-emacs))
|
|
306
|
|
307 ;; For machines with CANNOT_DUMP defined in config.h,
|
|
308 ;; this file must be loaded each time Emacs is run.
|
|
309 ;; So run the startup code now.
|
|
310
|
|
311 (when (not (fboundp 'dump-emacs))
|
|
312 ;; Avoid loading loadup.el a second time!
|
|
313 (setq command-line-args (cdr (cdr command-line-args)))
|
|
314 (eval top-level))
|
|
315
|
|
316 ;;; loadup.el ends here
|