1 ;; loadup.el --- load up standardly loaded Lisp files for XEmacs.
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.
7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: internal, dumped
10 ;; This file is part of XEmacs.
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)
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.
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
27 ;;; Synched up with: Last synched with FSF 19.30, with wild divergence since.
31 ;; Please do not edit this file. Use site-init.el or site-load.el instead.
33 ;; This is loaded into a bare XEmacs to make a dumpable one.
37 (when (fboundp 'error)
38 (error "loadup.el already loaded!"))
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.")
45 (defvar Installation-string nil
46 "Description of XEmacs installation.")
48 (let ((gc-cons-threshold 30000))
50 ;; This is awfully damn early to be getting an error, right?
51 (call-with-condition-handler 'really-early-error-handler
54 ;; Initialize Installation-string. We do it before loading
55 ;; anything so that dumped code can make use of its value.
56 (setq Installation-string
58 (set-buffer (get-buffer-create (generate-new-buffer-name
60 ;; insert-file-contents-internal bogusly calls
61 ;; format-decode without checking if it's defined.
62 (fset 'format-decode #'(lambda (f l &optional v) l))
63 (insert-file-contents-internal "../Installation")
64 (fmakunbound 'format-decode)
65 (prog1 (buffer-substring)
66 (kill-buffer (current-buffer)))))
68 (let ((build-root (expand-file-name ".." invocation-directory)))
69 (setq load-path (list (expand-file-name "lisp" build-root)))
70 (setq module-load-path (list (expand-file-name "modules" build-root))))
72 ;; message not defined yet ...
73 (external-debugging-output (format "\nUsing load-path %s" load-path))
74 (external-debugging-output (format "\nUsing module-load-path %s"
77 ;; We don't want to have any undo records in the dumped XEmacs.
78 (buffer-disable-undo (get-buffer "*scratch*"))
80 ;; Load our first bootstrap support
81 (load "very-early-lisp" nil t)
83 ;; lread.c (or src/Makefile.in.in) has prepended
84 ;; "${srcdir}/../lisp/" to load-path, which is how this file
85 ;; has been found. At this point, enough of XEmacs has been
86 ;; initialized that we can start dumping "standard" lisp.
87 ;; Dumped lisp from external packages is added when we search
89 ;; #### This code is duplicated in two other places.
90 (let ((temp-path (expand-file-name "." (car load-path))))
91 (setq load-path (nconc (mapcar
92 #'(lambda (i) (concat i "/"))
93 (directory-files temp-path t "^[^-.]"
95 (cons (file-name-as-directory temp-path)
98 (setq load-warn-when-source-newer t ; Used to be set to nil at the end
99 load-warn-when-source-only t) ; Set to nil at the end
101 ;; garbage collect after loading every file in an attempt to
102 ;; minimize the size of the dumped image (if we don't do this,
103 ;; there will be lots of extra space in the data segment filled
104 ;; with garbage-collected junk)
105 (defun pureload (file)
107 (locate-file file load-path
108 (if load-ignore-elc-files
109 '(".el" "") '(".elc" ".el" "")))))
114 (external-debugging-output (format "\nLoad file %s: not found\n"
116 ;; Uncomment in case of trouble
117 ;;(print (format "late-packages: %S" late-packages))
118 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name)))
121 (load (expand-file-name "../lisp/dumped-lisp.el"))
123 (let ((files preloaded-file-list)
125 (while (setq file (car files))
126 (unless (pureload file)
127 (external-debugging-output "Fatal error during load, aborting")
129 (setq files (cdr files)))
130 (when (not (featurep 'toolbar))
131 ;; else still define a few functions.
132 (defun toolbar-button-p (obj) "No toolbar support." nil)
133 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
134 (fmakunbound 'pureload))
136 (packages-load-package-dumped-lisps late-package-load-path)
138 )) ;; end of call-with-condition-handler
140 ;; Fix up the preloaded file list
141 (setq preloaded-file-list (mapcar #'file-name-sans-extension
142 preloaded-file-list))
144 (setq load-warn-when-source-newer t ; set to t at top of file
145 load-warn-when-source-only nil)
147 (setq debugger 'debug)
149 (when (member "no-site-file" command-line-args)
150 (setq site-start-file nil))
152 ;; If you want additional libraries to be preloaded and their
153 ;; doc strings kept in the DOC file rather than in core,
154 ;; you may load them with a "site-load.el" file.
155 ;; But you must also cause them to be scanned when the DOC file
156 ;; is generated. For VMS, you must edit ../../vms/makedoc.com.
157 ;; For other systems, you must edit ../../src/Makefile.in.in.
158 (when (load "site-load" t)
162 ;;(if (fboundp 'x-popup-menu)
163 ;; (precompute-menubar-bindings))
164 ;;; Turn on recording of which commands get rebound,
165 ;;; for the sake of the next call to precompute-menubar-bindings.
166 ;(setq define-key-rebound-commands nil)
168 ;; Note: all compiled Lisp files loaded above this point
169 ;; must be among the ones parsed by make-docfile
170 ;; to construct DOC. Any that are not processed
171 ;; for DOC will not have doc strings in the dumped XEmacs.
173 ;; Don't bother with these if we're running temacs, i.e. if we're
174 ;; just debugging don't waste time finding doc strings.
176 ;; purify-flag is nil if called from loadup-el.el.
178 (message "Finding pointers to doc strings...")
179 (Snarf-documentation "DOC")
180 (message "Finding pointers to doc strings...done")
181 (Verify-documentation))
183 ;; Note: You can cause additional libraries to be preloaded
184 ;; by writing a site-init.el that loads them.
185 ;; See also "site-load" above.
186 (when (stringp site-start-file)
187 (load "site-init" t))
188 (setq current-load-list nil)
191 ;;; At this point, we're ready to resume undo recording for scratch.
192 (buffer-enable-undo "*scratch*")
194 ) ;; frequent garbage collection
196 ;; Dump into the name `xemacs' (only)
197 (when (member "dump" command-line-args)
198 (message "Dumping under the name xemacs")
199 ;; This is handled earlier in the build process.
200 ;; (condition-case () (delete-file "xemacs") (file-error nil))
201 (when (fboundp 'really-free)
203 (dump-emacs (if (featurep 'infodock) "infodock" "xemacs") "temacs")
206 ;; Avoid error if user loads some more libraries now.
207 (setq purify-flag nil)
209 (when (member "run-temacs" command-line-args)
210 (message "\nBootstrapping from temacs...")
211 ;; Remove all args up to and including "run-temacs"
212 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
213 ;; run-emacs-from-temacs doesn't actually return anyway.
217 ;; If you are using 'recompile', then you should have used -l loadup-el.el
218 ;; so that the .el files always get loaded (the .elc files may be out-of-
220 (when (member "recompile" command-line-args)
221 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
222 (batch-byte-recompile-directory)
225 ;; For machines with CANNOT_DUMP defined in config.h,
226 ;; this file must be loaded each time Emacs is run.
227 ;; So run the startup code now.
229 (when (not (fboundp 'dump-emacs))
230 ;; Avoid loading loadup.el a second time!
231 (setq command-line-args (cdr (cdr command-line-args)))
234 ;;; loadup.el ends here