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.")
46 (let ((gc-cons-threshold 30000))
48 ;; This is awfully damn early to be getting an error, right?
49 (call-with-condition-handler 'really-early-error-handler
51 ;; message not defined yet ...
52 (setq load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH")))
53 (setq module-load-path (split-path (getenv "EMACSBOOTSTRAPMODULEPATH")))
55 (external-debugging-output (format "\nUsing load-path %s" load-path))
56 (external-debugging-output (format "\nUsing module-load-path %s" module-load-path))
58 ;; We don't want to have any undo records in the dumped XEmacs.
59 (buffer-disable-undo (get-buffer "*scratch*"))
61 ;; Load our first bootstrap support
62 (load "very-early-lisp" nil t)
64 ;; lread.c (or src/Makefile.in.in) has prepended
65 ;; "${srcdir}/../lisp/" to load-path, which is how this file
66 ;; has been found. At this point, enough of XEmacs has been
67 ;; initialized that we can start dumping "standard" lisp.
68 ;; Dumped lisp from external packages is added when we search
70 ;; #### This code is duplicated in two other places.
71 (let ((temp-path (expand-file-name "." (car load-path))))
72 (setq load-path (nconc (mapcar
73 #'(lambda (i) (concat i "/"))
74 (directory-files temp-path t "^[^-.]"
76 (cons (file-name-as-directory temp-path)
79 (setq load-warn-when-source-newer t ; Used to be set to nil at the end
80 load-warn-when-source-only t) ; Set to nil at the end
82 ;; garbage collect after loading every file in an attempt to
83 ;; minimize the size of the dumped image (if we don't do this,
84 ;; there will be lots of extra space in the data segment filled
85 ;; with garbage-collected junk)
86 (defun pureload (file)
88 (locate-file file load-path
89 (if load-ignore-elc-files ".el:" ".elc:.el:"))))
94 (external-debugging-output (format "\nLoad file %s: not found\n"
96 ;; Uncomment in case of trouble
97 ;;(print (format "late-packages: %S" late-packages))
98 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name)))
101 (load (concat default-directory "../lisp/dumped-lisp.el"))
103 (let ((files preloaded-file-list)
105 (while (setq file (car files))
106 (unless (pureload file)
107 (external-debugging-output "Fatal error during load, aborting")
109 (setq files (cdr files)))
110 (when (not (featurep 'toolbar))
111 ;; else still define a few functions.
112 (defun toolbar-button-p (obj) "No toolbar support." nil)
113 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
114 (fmakunbound 'pureload))
116 (packages-load-package-dumped-lisps late-package-load-path)
118 )) ;; end of call-with-condition-handler
120 ;; Fix up the preloaded file list
121 (setq preloaded-file-list (mapcar #'file-name-sans-extension
122 preloaded-file-list))
124 (setq load-warn-when-source-newer t ; set to t at top of file
125 load-warn-when-source-only nil)
127 (setq debugger 'debug)
129 (when (member "no-site-file" command-line-args)
130 (setq site-start-file nil))
132 ;; If you want additional libraries to be preloaded and their
133 ;; doc strings kept in the DOC file rather than in core,
134 ;; you may load them with a "site-load.el" file.
135 ;; But you must also cause them to be scanned when the DOC file
136 ;; is generated. For VMS, you must edit ../../vms/makedoc.com.
137 ;; For other systems, you must edit ../../src/Makefile.in.in.
138 (when (load "site-load" t)
142 ;;(if (fboundp 'x-popup-menu)
143 ;; (precompute-menubar-bindings))
144 ;;; Turn on recording of which commands get rebound,
145 ;;; for the sake of the next call to precompute-menubar-bindings.
146 ;(setq define-key-rebound-commands nil)
149 ;; Note: all compiled Lisp files loaded above this point
150 ;; must be among the ones parsed by make-docfile
151 ;; to construct DOC. Any that are not processed
152 ;; for DOC will not have doc strings in the dumped XEmacs.
154 ;; Don't bother with these if we're running temacs, i.e. if we're
155 ;; just debugging don't waste time finding doc strings.
157 ;; purify-flag is nil if called from loadup-el.el.
159 (message "Finding pointers to doc strings...")
160 (Snarf-documentation "DOC")
161 (message "Finding pointers to doc strings...done")
162 (Verify-documentation))
164 ;; Note: You can cause additional libraries to be preloaded
165 ;; by writing a site-init.el that loads them.
166 ;; See also "site-load" above.
167 (when (stringp site-start-file)
168 (load "site-init" t))
169 (setq current-load-list nil)
172 ;;; At this point, we're ready to resume undo recording for scratch.
173 (buffer-enable-undo "*scratch*")
175 ) ;; frequent garbage collection
177 ;; Dump into the name `xemacs' (only)
178 (when (member "dump" command-line-args)
179 (message "Dumping under the name xemacs")
180 ;; This is handled earlier in the build process.
181 ;; (condition-case () (delete-file "xemacs") (file-error nil))
182 (when (fboundp 'really-free)
184 (dump-emacs (if (featurep 'infodock) "infodock" "xemacs") "temacs")
187 ;; Avoid error if user loads some more libraries now.
188 (setq purify-flag nil)
190 (when (member "run-temacs" command-line-args)
191 (message "\nBootstrapping from temacs...")
192 ;; Remove all args up to and including "run-temacs"
193 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
194 ;; run-emacs-from-temacs doesn't actually return anyway.
198 ;; If you are using 'recompile', then you should have used -l loadup-el.el
199 ;; so that the .el files always get loaded (the .elc files may be out-of-
201 (when (member "recompile" command-line-args)
202 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
203 (batch-byte-recompile-directory)
206 ;; For machines with CANNOT_DUMP defined in config.h,
207 ;; this file must be loaded each time Emacs is run.
208 ;; So run the startup code now.
210 (when (not (fboundp 'dump-emacs))
211 ;; Avoid loading loadup.el a second time!
212 (setq command-line-args (cdr (cdr command-line-args)))
215 ;;; loadup.el ends here