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