(pure-space-overflow): New variable.
[bpt/emacs.git] / lisp / loadup.el
CommitLineData
55535639 1;;; loadup.el --- load up standardly loaded Lisp files for Emacs
6594deb0 2
5db04750 3;; Copyright (C) 1985, 1986, 1992, 1994, 2001 Free Software Foundation, Inc.
eea8d4ef 4
e5167999 5;; Maintainer: FSF
fd7fa35a 6;; Keywords: internal
e5167999 7
0d20f9a0
JB
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
e5167999 12;; the Free Software Foundation; either version 2, or (at your option)
0d20f9a0
JB
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
b578f267
EN
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
0d20f9a0 24
eea8d4ef
ER
25;;; Commentary:
26
27;; This is loaded into a bare Emacs to make a dumpable one.
28
e5167999
ER
29;;; Code:
30
ce87039d
SM
31;; add subdirectories to the load-path for files that might
32;; get autoloaded when bootstrapping
33(if (or (equal (nth 3 command-line-args) "bootstrap")
49fc4500
KR
34 (equal (nth 4 command-line-args) "bootstrap")
35 ;; in case CANNOT_DUMP
36 (equal (nth 0 command-line-args) "../src/bootstrap-emacs"))
ceec5b6d 37 (let ((dir (car load-path)))
397869a4
SM
38 ;; We'll probably overflow the pure space.
39 (setq purify-flag nil)
ceec5b6d
RS
40 (setq load-path (list dir
41 (expand-file-name "emacs-lisp" dir)
42 (expand-file-name "language" dir)
43 (expand-file-name "international" dir)
44 (expand-file-name "textmodes" dir)))))
ce87039d 45
8c74709f 46(message "Using load-path %s" load-path)
8c74709f 47
86db31d5 48;; We don't want to have any undo records in the dumped Emacs.
ffd56f97 49(buffer-disable-undo "*scratch*")
0d20f9a0 50
693e59d6 51(load "emacs-lisp/byte-run")
86db31d5 52(load "emacs-lisp/backquote")
0d20f9a0 53(load "subr")
15897347
RS
54
55;; We specify .el in case someone compiled version.el by mistake.
56(load "version.el")
57
d038ca1d 58(load "widget")
d038ca1d 59(load "custom")
693e59d6 60(load "emacs-lisp/map-ynp")
b27f23c1 61(load "env")
4d100a01 62(load "cus-start")
5dcd1261 63(load "international/mule")
5dcd1261 64(load "international/mule-conf.el") ;Don't get confused if someone compiled this by mistake.
8f89dc56 65(load "format")
9b73022f
RS
66(load "bindings")
67(setq load-source-file-function 'load-with-code-conversion)
0d20f9a0 68(load "files")
838d57f6 69
3fad47d8 70(load "cus-face")
d6af189a
MB
71(load "faces") ; after here, `defface' may be used.
72
6f76277f
RS
73(message "Lists of integers (garbage collection statistics) are normal output")
74(message "while building Emacs; they do not indicate a problem.")
838d57f6
RS
75(message "%s" (garbage-collect))
76(load "loaddefs.el") ;Don't get confused if someone compiled this by mistake.
77(message "%s" (garbage-collect))
3bce0243 78(load "simple")
838d57f6 79
301d6830 80(load "help")
d6af189a 81
301d6830
GM
82;; Any Emacs Lisp source file (*.el) loaded here after can contain
83;; multilingual text.
84(load "international/mule-cmds")
85(load "case-table")
c546dfcb 86(load "international/utf-8")
0405f493 87(load "international/utf-16")
b0c654c0 88(load "international/characters")
301d6830 89
939f6e3f 90(let ((set-case-syntax-set-multibyte t))
5dcd1261
RS
91 (load "international/latin-1")
92 (load "international/latin-2")
93 (load "international/latin-3")
94 (load "international/latin-4")
902e7be8
DL
95 (load "international/latin-5")
96 (load "international/latin-8")
97 (load "international/latin-9"))
8f89dc56 98;; Load language-specific files.
5e14f0f5 99(load "language/chinese")
5e14f0f5 100(load "language/cyrillic")
5e14f0f5 101(load "language/indian")
f5ef6d1f
KH
102(load "language/devanagari") ; This should be loaded after indian.
103(load "language/malayalam") ; This should be loaded after indian.
104(load "language/tamil") ; This should be loaded after indian.
4366b45e 105(load "language/english")
5e14f0f5 106(load "language/ethiopic")
5e14f0f5 107(load "language/european")
c90c0be0
RS
108(load "language/czech")
109(load "language/slovak")
23e7714e 110(load "language/romanian")
5e14f0f5 111(load "language/greek")
5e14f0f5 112(load "language/hebrew")
5e14f0f5 113(load "language/japanese")
5e14f0f5 114(load "language/korean")
f35c859c 115(load "language/lao")
5e14f0f5 116(load "language/thai")
4366b45e 117(load "language/tibetan")
5e14f0f5 118(load "language/vietnamese")
5e14f0f5 119(load "language/misc-lang")
69c34764
DL
120(load "language/utf-8-lang")
121(load "language/georgian")
86db31d5
SM
122
123(load "international/ucs-tables")
86db31d5 124
4298d95e 125(update-coding-systems-internal)
838d57f6 126
0d20f9a0
JB
127(load "indent")
128(load "window")
fd727f4a 129(load "frame")
f795f633 130(load "term/tty-colors")
63a29a5d 131(load "font-core")
d6af189a 132
7a701b9f
KH
133(if (fboundp 'frame-face-alist)
134 (progn
7a701b9f
KH
135 (load "facemenu")))
136(if (fboundp 'track-mouse)
137 (progn
7a701b9f 138 (load "mouse")
9315353b 139 (and (boundp 'x-toolkit-scroll-bars)
449ab688 140 (load "scroll-bar"))
36974751 141 (load "select")))
693e59d6 142(load "emacs-lisp/timer")
01c86c56 143(load "isearch")
838d57f6
RS
144
145(message "%s" (garbage-collect))
afcd9910 146(load "menu-bar")
0d20f9a0 147(load "paths.el") ;Don't get confused if someone compiled paths by mistake.
0d20f9a0 148(load "startup")
5dcd1261 149(load "emacs-lisp/lisp")
5dcd1261 150(load "textmodes/page")
0d20f9a0 151(load "register")
5dcd1261 152(load "textmodes/paragraphs")
5dcd1261 153(load "emacs-lisp/lisp-mode")
5dcd1261 154(load "textmodes/text-mode")
5dcd1261 155(load "textmodes/fill")
838d57f6
RS
156(message "%s" (garbage-collect))
157
0d20f9a0
JB
158(load "replace")
159(if (eq system-type 'vax-vms)
160 (progn
0d20f9a0 161 (load "vmsproc")))
0d20f9a0 162(load "abbrev")
0d20f9a0
JB
163(load "buff-menu")
164(if (eq system-type 'vax-vms)
165 (progn
0d20f9a0 166 (load "vms-patch")))
b7521474
RS
167(if (eq system-type 'windows-nt)
168 (progn
b7521474 169 (load "ls-lisp")
234ae99a 170 (load "disp-table") ; needed to setup ibm-pc char set, see internal.el
489f9371 171 (load "dos-w32")
9c6a562b 172 (load "w32-vars")
63abf612 173 (load "w32-fns")))
ed10e0ab
RS
174(if (eq system-type 'ms-dos)
175 (progn
176 (load "ls-lisp")
489f9371 177 (load "dos-w32")
ed10e0ab 178 (load "dos-fns")
7298263a 179 (load "dos-vars")
6f676109 180 (load "international/ccl") ; codepage.el uses CCL en/decoder
aea543b4 181 (load "international/codepage") ; internal.el uses cpNNN coding systems
63abf612 182 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
591b63b4
AC
183(if (eq system-type 'macos)
184 (progn
185 (load "ls-lisp")))
e04d21aa 186(if (fboundp 'atan) ; preload some constants and
63abf612 187 (progn ; floating pt. functions if we have float support.
693e59d6 188 (load "emacs-lisp/float-sup")))
838d57f6 189(message "%s" (garbage-collect))
e4636528 190
637a8ae9 191(load "vc-hooks")
a63926db 192(load "ediff-hook")
838d57f6 193(message "%s" (garbage-collect))
0d20f9a0
JB
194
195;If you want additional libraries to be preloaded and their
196;doc strings kept in the DOC file rather than in core,
197;you may load them with a "site-load.el" file.
198;But you must also cause them to be scanned when the DOC file
87855006 199;is generated. For VMS, you must edit ../vms/makedoc.com.
fd322fae 200;For other systems, you must edit ../src/Makefile.in.
0d20f9a0
JB
201(if (load "site-load" t)
202 (garbage-collect))
203
f5263a5c
RS
204(if (fboundp 'x-popup-menu)
205 (precompute-menubar-bindings))
206;; Turn on recording of which commands get rebound,
207;; for the sake of the next call to precompute-menubar-bindings.
208(setq define-key-rebound-commands nil)
209
de78a7ba
RS
210;; Determine which last version number to use
211;; based on the executables that now exist.
24cffc68
RS
212(if (and (or (equal (nth 3 command-line-args) "dump")
213 (equal (nth 4 command-line-args) "dump"))
214 (not (eq system-type 'ms-dos)))
0c39a403 215 (let* ((base (concat "emacs-" emacs-version "."))
de78a7ba
RS
216 (files (file-name-all-completions base default-directory))
217 (versions (mapcar (function (lambda (name)
9b04b1b7 218 (string-to-int (substring name (length base)))))
de78a7ba 219 files)))
86db31d5
SM
220 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
221 (defconst emacs-version
222 (format "%s.%d"
223 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
de78a7ba 224
0d20f9a0
JB
225;; Note: all compiled Lisp files loaded above this point
226;; must be among the ones parsed by make-docfile
227;; to construct DOC. Any that are not processed
228;; for DOC will not have doc strings in the dumped Emacs.
229
230(message "Finding pointers to doc strings...")
24cffc68
RS
231(if (or (equal (nth 3 command-line-args) "dump")
232 (equal (nth 4 command-line-args) "dump"))
0d20f9a0
JB
233 (let ((name emacs-version))
234 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
235 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
236 "-"
237 (substring name (match-end 0)))))
b7521474 238 (if (memq system-type '(ms-dos windows-nt))
87485d6f 239 (setq name (expand-file-name
753a134f 240 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
ed10e0ab
RS
241 (setq name (concat (expand-file-name "../etc/DOC-") name))
242 (if (file-exists-p name)
243 (delete-file name))
244 (copy-file (expand-file-name "../etc/DOC") name t))
450a90e2 245 (Snarf-documentation (file-name-nondirectory name)))
ce87039d
SM
246 (condition-case nil
247 (Snarf-documentation "DOC")
248 (error nil)))
0d20f9a0
JB
249(message "Finding pointers to doc strings...done")
250
0f4b266c
KH
251;;;Note: You can cause additional libraries to be preloaded
252;;;by writing a site-init.el that loads them.
253;;;See also "site-load" above.
0d20f9a0 254(load "site-init" t)
95227eb2 255(setq current-load-list nil)
c2509060 256
b7b75652
AS
257;; Write the value of load-history into fns-VERSION.el,
258;; then clear out load-history.
4744f265
SM
259;; (if (or (equal (nth 3 command-line-args) "dump")
260;; (equal (nth 4 command-line-args) "dump"))
261;; (let ((buffer-undo-list t))
262;; (princ "(setq load-history\n" (current-buffer))
263;; (princ " (nconc load-history\n" (current-buffer))
264;; (princ " '(" (current-buffer))
265;; (let ((tem load-history))
266;; (while tem
267;; (prin1 (car tem) (current-buffer))
268;; (terpri (current-buffer))
269;; (if (cdr tem)
270;; (princ " " (current-buffer)))
271;; (setq tem (cdr tem))))
272;; (princ ")))\n" (current-buffer))
273;; (write-region (point-min) (point-max)
274;; (expand-file-name
275;; (cond
276;; ((eq system-type 'ms-dos)
277;; "../lib-src/fns.el")
278;; ((eq system-type 'windows-nt)
279;; (format "../../../lib-src/fns-%s.el" emacs-version))
280;; (t
281;; (format "../lib-src/fns-%s.el" emacs-version)))
282;; invocation-directory))
283;; (erase-buffer)
284;; (setq load-history nil))
285;; (setq symbol-file-load-history-loaded t))
286;; We don't use this fns-*.el file. Instead we keep the data in PURE space.
287;; Make sure that the spine of the list is not in pure space because it can
288;; be destructively mutated in lread.c:build_load_history.
289(setq load-history (mapcar 'purecopy load-history))
290(setq symbol-file-load-history-loaded t)
291
b7b75652 292(set-buffer-modified-p nil)
c2509060 293
ce87039d
SM
294;; reset the load-path. See lread.c:init_lread why.
295(if (or (equal (nth 3 command-line-args) "bootstrap")
296 (equal (nth 4 command-line-args) "bootstrap"))
297 (setcdr load-path nil))
298
0d20f9a0
JB
299(garbage-collect)
300
ffd56f97
JB
301;;; At this point, we're ready to resume undo recording for scratch.
302(buffer-enable-undo "*scratch*")
303
ce87039d
SM
304(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
305 (member (nth 4 command-line-args) '("dump" "bootstrap")))
0d20f9a0 306 (if (eq system-type 'vax-vms)
e04d21aa 307 (progn
0d20f9a0
JB
308 (message "Dumping data as file temacs.dump")
309 (dump-emacs "temacs.dump" "temacs")
310 (kill-emacs))
311 (let ((name (concat "emacs-" emacs-version)))
312 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
313 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
314 "-"
315 (substring name (match-end 0)))))
ed10e0ab
RS
316 (if (eq system-type 'ms-dos)
317 (message "Dumping under the name emacs")
318 (message "Dumping under names emacs and %s" name)))
0d20f9a0 319 (condition-case ()
59f3e9a2 320 (delete-file "emacs")
0d20f9a0 321 (file-error nil))
59f3e9a2
JB
322 ;; We used to dump under the name xemacs, but that occasionally
323 ;; confused people installing Emacs (they'd install the file
324 ;; under the name `xemacs'), and it's inconsistent with every
0f4b266c 325 ;; other GNU program's build process.
59f3e9a2 326 (dump-emacs "emacs" "temacs")
4d337390 327 (message "%d pure bytes used" pure-bytes-used)
0d20f9a0 328 ;; Recompute NAME now, so that it isn't set when we dump.
ea3e2043 329 (if (not (memq system-type '(ms-dos windows-nt)))
ed10e0ab
RS
330 (let ((name (concat "emacs-" emacs-version)))
331 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
332 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
333 "-"
334 (substring name (match-end 0)))))
335 (add-name-to-file "emacs" name t)))
0d20f9a0
JB
336 (kill-emacs)))
337
338;; Avoid error if user loads some more libraries now.
339(setq purify-flag nil)
340
341;; For machines with CANNOT_DUMP defined in config.h,
342;; this file must be loaded each time Emacs is run.
7fa26c0a 343;; So run the startup code now. First, remove `-l loadup' from args.
0d20f9a0 344
7fa26c0a
KH
345(if (and (equal (nth 1 command-line-args) "-l")
346 (equal (nth 2 command-line-args) "loadup"))
347 (setcdr command-line-args (nthcdr 3 command-line-args)))
348
349(eval top-level)
6594deb0 350
86db31d5
SM
351\f
352;;; Local Variables:
353;;; no-byte-compile: t
354;;; no-update-autoloads: t
355;;; End:
6594deb0 356;;; loadup.el ends here