* trouble.texi (Contributing): Repository is no longer CVS.
[bpt/emacs.git] / lisp / loadup.el
CommitLineData
55535639 1;;; loadup.el --- load up standardly loaded Lisp files for Emacs
6594deb0 2
4f32d22e 3;; Copyright (C) 1985, 1986, 1992, 1994, 2001, 2002, 2003, 2004, 2005,
114f9c96 4;; 2006, 2007, 2008, 2009, 2010 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
eb3fa2cf 11;; GNU Emacs is free software: you can redistribute it and/or modify
0d20f9a0 12;; it under the terms of the GNU General Public License as published by
eb3fa2cf
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
0d20f9a0
JB
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
eb3fa2cf 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
0d20f9a0 23
eea8d4ef
ER
24;;; Commentary:
25
26;; This is loaded into a bare Emacs to make a dumpable one.
27
607b8307
GM
28;; If you add/remove Lisp files to be loaded here, consider the
29;; following issues:
30
31;; i) Any file loaded on all platforms should appear in $lisp
32;; and $shortlisp in src/Makefile.in. Use the .el or .elc version as
33;; appropriate.
34
35;; ii) Any file that is only loaded on some platforms should appear
36;; in the version of $lisp in the generated Makefile on that platform.
37;; At the present time, this is achieved by use of #ifdefs.
38;; It should also appear in $SOME_MACHINE_LISP on all platforms.
39
40;; The above steps ensure both that the Lisp files are compiled (if
41;; necessary) before the emacs executable is dumped, and that they are
42;; passed to make-docfile. (Any that are not processed for DOC will
43;; not have doc strings in the dumped Emacs.) Because of this:
44
45;; iii) If the file is loaded uncompiled, it should (where possible)
46;; obey the doc-string conventions expected by make-docfile.
47
e5167999
ER
48;;; Code:
49
607b8307
GM
50;; Add subdirectories to the load-path for files that might get
51;; autoloaded when bootstrapping.
ce87039d 52(if (or (equal (nth 3 command-line-args) "bootstrap")
49fc4500 53 (equal (nth 4 command-line-args) "bootstrap")
3579a658
KH
54 (equal (nth 3 command-line-args) "unidata-gen.el")
55 (equal (nth 4 command-line-args) "unidata-gen-files")
607b8307 56 ;; In case CANNOT_DUMP.
49fc4500 57 (equal (nth 0 command-line-args) "../src/bootstrap-emacs"))
ceec5b6d 58 (let ((dir (car load-path)))
397869a4
SM
59 ;; We'll probably overflow the pure space.
60 (setq purify-flag nil)
ceec5b6d
RS
61 (setq load-path (list dir
62 (expand-file-name "emacs-lisp" dir)
63 (expand-file-name "language" dir)
64 (expand-file-name "international" dir)
65 (expand-file-name "textmodes" dir)))))
ce87039d 66
8c74709f 67(message "Using load-path %s" load-path)
8c74709f 68
8c766df1
KH
69(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
70 (member (nth 4 command-line-args) '("dump" "bootstrap")))
71 ;; To reduce the size of dumped Emacs, we avoid making huge
72 ;; char-tables.
73 (setq inhibit-load-charset-map t))
74
86db31d5 75;; We don't want to have any undo records in the dumped Emacs.
f6e43712
RS
76(set-buffer "*scratch*")
77(setq buffer-undo-list t)
0d20f9a0 78
693e59d6 79(load "emacs-lisp/byte-run")
86db31d5 80(load "emacs-lisp/backquote")
0d20f9a0 81(load "subr")
15897347 82
0e328d37
SM
83;; Do it after subr, since both after-load-functions and add-hook are
84;; implemented in subr.el.
85(add-hook 'after-load-functions '(lambda (f) (garbage-collect)))
86
15897347
RS
87;; We specify .el in case someone compiled version.el by mistake.
88(load "version.el")
89
d038ca1d 90(load "widget")
d038ca1d 91(load "custom")
693e59d6 92(load "emacs-lisp/map-ynp")
4d100a01 93(load "cus-start")
5dcd1261 94(load "international/mule")
a042de45 95(load "international/mule-conf")
911650d2 96(load "env")
8f89dc56 97(load "format")
9b73022f
RS
98(load "bindings")
99(setq load-source-file-function 'load-with-code-conversion)
0d20f9a0 100(load "files")
838d57f6 101
3fad47d8 102(load "cus-face")
d6af189a 103(load "faces") ; after here, `defface' may be used.
beec574c 104(load "minibuffer")
d6af189a 105
d4e9f067
JL
106(load "button")
107(load "startup")
108
23c2e0e4
SM
109(condition-case nil
110 ;; Don't get confused if someone compiled this by mistake.
111 (load "loaddefs.el")
112 ;; In case loaddefs hasn't been generated yet.
113 (file-error (load "ldefs-boot.el")))
114
e2947429 115(load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
3bce0243 116(load "simple")
838d57f6 117
301d6830 118(load "help")
d6af189a 119
274925df 120(load "jka-cmpr-hook")
8900c52c 121(load "epa-hook")
301d6830
GM
122;; Any Emacs Lisp source file (*.el) loaded here after can contain
123;; multilingual text.
124(load "international/mule-cmds")
125(load "case-table")
b0c654c0 126(load "international/characters")
d8b52430 127(load "composite")
90ce1bb9
KH
128;; This file doesn't exist when building Emacs from CVS. It is
129;; generated just after temacs is build.
130(load "international/charprop.el" t)
301d6830 131
8f89dc56 132;; Load language-specific files.
5e14f0f5 133(load "language/chinese")
5e14f0f5 134(load "language/cyrillic")
5e14f0f5 135(load "language/indian")
43d8c495 136(load "language/sinhala")
4366b45e 137(load "language/english")
5e14f0f5 138(load "language/ethiopic")
5e14f0f5 139(load "language/european")
c90c0be0
RS
140(load "language/czech")
141(load "language/slovak")
23e7714e 142(load "language/romanian")
5e14f0f5 143(load "language/greek")
5e14f0f5 144(load "language/hebrew")
5e14f0f5 145(load "language/japanese")
5e14f0f5 146(load "language/korean")
f35c859c 147(load "language/lao")
201bc379 148(load "language/tai-viet")
5e14f0f5 149(load "language/thai")
4366b45e 150(load "language/tibetan")
5e14f0f5 151(load "language/vietnamese")
5e14f0f5 152(load "language/misc-lang")
69c34764
DL
153(load "language/utf-8-lang")
154(load "language/georgian")
44f44190 155(load "language/khmer")
f81e37a0 156(load "language/burmese")
b03e8a93 157(load "language/cham")
86db31d5 158
0d20f9a0
JB
159(load "indent")
160(load "window")
fd727f4a 161(load "frame")
f795f633 162(load "term/tty-colors")
63a29a5d 163(load "font-core")
633537d7
LT
164;; facemenu must be loaded before font-lock, because `facemenu-keymap'
165;; needs to be defined when font-lock is loaded.
a4a19809 166(load "facemenu")
c94f08ff
DN
167(load "emacs-lisp/syntax")
168(load "font-lock")
169(load "jit-lock")
d6af189a 170
7a701b9f
KH
171(if (fboundp 'track-mouse)
172 (progn
7a701b9f 173 (load "mouse")
9315353b 174 (and (boundp 'x-toolkit-scroll-bars)
449ab688 175 (load "scroll-bar"))
36974751 176 (load "select")))
693e59d6 177(load "emacs-lisp/timer")
01c86c56 178(load "isearch")
1f423851 179(load "rfn-eshadow")
838d57f6 180
afcd9910 181(load "menu-bar")
0d20f9a0 182(load "paths.el") ;Don't get confused if someone compiled paths by mistake.
5dcd1261 183(load "emacs-lisp/lisp")
5dcd1261 184(load "textmodes/page")
0d20f9a0 185(load "register")
5dcd1261 186(load "textmodes/paragraphs")
5dcd1261 187(load "emacs-lisp/lisp-mode")
5dcd1261 188(load "textmodes/text-mode")
5dcd1261 189(load "textmodes/fill")
838d57f6 190
0d20f9a0 191(load "replace")
0d20f9a0 192(load "buff-menu")
165b0fa0
RS
193
194(if (fboundp 'x-create-frame)
195 (progn
e541cbfc 196 (load "fringe")
165b0fa0
RS
197 (load "image")
198 (load "international/fontset")
199 (load "dnd")
165b0fa0 200 (load "tool-bar")))
637fa988
JD
201
202(if (or (featurep 'system-font-setting) (featurep 'font-render-setting))
203 (load "font-setting"))
204
165b0fa0 205(if (featurep 'x)
ddaa8057 206 (progn
9d488d86 207 (load "x-dnd")
d5e4dda5 208 (load "term/common-win")
79c3172f 209 (load "term/x-win")))
d5e4dda5 210
b7521474
RS
211(if (eq system-type 'windows-nt)
212 (progn
729f1525 213 (load "w32-vars")
d5e4dda5 214 (load "term/common-win")
ddaa8057 215 (load "term/w32-win")
b7521474 216 (load "ls-lisp")
bbe44805 217 (load "disp-table")
489f9371 218 (load "dos-w32")
63abf612 219 (load "w32-fns")))
ed10e0ab
RS
220(if (eq system-type 'ms-dos)
221 (progn
489f9371 222 (load "dos-w32")
ed10e0ab 223 (load "dos-fns")
7298263a 224 (load "dos-vars")
bbe44805
EZ
225 ;; Don't load term/common-win: it isn't appropriate for the `pc'
226 ;; ``window system'', which generally behaves like a terminal.
227 (load "term/pc-win")
228 (load "ls-lisp")
63abf612 229 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
601fb9b8 230(if (featurep 'ns)
edfda783
AR
231 (progn
232 (load "emacs-lisp/easymenu") ;; for platform-related menu adjustments
edfda783 233 (load "term/ns-win")))
ab5c0fcd
SM
234(if (fboundp 'x-create-frame)
235 ;; Do it after loading term/foo-win.el since the value of the
236 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
237 (load "mwheel"))
e04d21aa 238(if (fboundp 'atan) ; preload some constants and
63abf612 239 (progn ; floating pt. functions if we have float support.
693e59d6 240 (load "emacs-lisp/float-sup")))
e4636528 241
637a8ae9 242(load "vc-hooks")
a63926db 243(load "ediff-hook")
8a902fd2 244(if (fboundp 'x-show-tip) (load "tooltip"))
165b0fa0 245
0d20f9a0
JB
246;If you want additional libraries to be preloaded and their
247;doc strings kept in the DOC file rather than in core,
248;you may load them with a "site-load.el" file.
249;But you must also cause them to be scanned when the DOC file
7c2fb837 250;is generated.
fd322fae 251;For other systems, you must edit ../src/Makefile.in.
0e328d37 252(load "site-load" t)
0d20f9a0 253
de78a7ba
RS
254;; Determine which last version number to use
255;; based on the executables that now exist.
24cffc68
RS
256(if (and (or (equal (nth 3 command-line-args) "dump")
257 (equal (nth 4 command-line-args) "dump"))
258 (not (eq system-type 'ms-dos)))
0c39a403 259 (let* ((base (concat "emacs-" emacs-version "."))
de78a7ba
RS
260 (files (file-name-all-completions base default-directory))
261 (versions (mapcar (function (lambda (name)
9b04b1b7 262 (string-to-int (substring name (length base)))))
de78a7ba 263 files)))
86db31d5
SM
264 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
265 (defconst emacs-version
266 (format "%s.%d"
267 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
de78a7ba 268
0d20f9a0
JB
269
270(message "Finding pointers to doc strings...")
24cffc68
RS
271(if (or (equal (nth 3 command-line-args) "dump")
272 (equal (nth 4 command-line-args) "dump"))
0d20f9a0
JB
273 (let ((name emacs-version))
274 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
275 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
276 "-"
277 (substring name (match-end 0)))))
b7521474 278 (if (memq system-type '(ms-dos windows-nt))
87485d6f 279 (setq name (expand-file-name
753a134f 280 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
ed10e0ab
RS
281 (setq name (concat (expand-file-name "../etc/DOC-") name))
282 (if (file-exists-p name)
283 (delete-file name))
284 (copy-file (expand-file-name "../etc/DOC") name t))
450a90e2 285 (Snarf-documentation (file-name-nondirectory name)))
ce87039d
SM
286 (condition-case nil
287 (Snarf-documentation "DOC")
288 (error nil)))
0d20f9a0
JB
289(message "Finding pointers to doc strings...done")
290
0f4b266c
KH
291;;;Note: You can cause additional libraries to be preloaded
292;;;by writing a site-init.el that loads them.
293;;;See also "site-load" above.
0d20f9a0 294(load "site-init" t)
95227eb2 295(setq current-load-list nil)
c2509060 296
b7b75652
AS
297;; Write the value of load-history into fns-VERSION.el,
298;; then clear out load-history.
4744f265
SM
299;; (if (or (equal (nth 3 command-line-args) "dump")
300;; (equal (nth 4 command-line-args) "dump"))
301;; (let ((buffer-undo-list t))
302;; (princ "(setq load-history\n" (current-buffer))
303;; (princ " (nconc load-history\n" (current-buffer))
304;; (princ " '(" (current-buffer))
305;; (let ((tem load-history))
306;; (while tem
307;; (prin1 (car tem) (current-buffer))
308;; (terpri (current-buffer))
309;; (if (cdr tem)
310;; (princ " " (current-buffer)))
311;; (setq tem (cdr tem))))
312;; (princ ")))\n" (current-buffer))
313;; (write-region (point-min) (point-max)
314;; (expand-file-name
315;; (cond
316;; ((eq system-type 'ms-dos)
317;; "../lib-src/fns.el")
318;; ((eq system-type 'windows-nt)
319;; (format "../../../lib-src/fns-%s.el" emacs-version))
320;; (t
321;; (format "../lib-src/fns-%s.el" emacs-version)))
322;; invocation-directory))
323;; (erase-buffer)
324;; (setq load-history nil))
325;; (setq symbol-file-load-history-loaded t))
326;; We don't use this fns-*.el file. Instead we keep the data in PURE space.
327;; Make sure that the spine of the list is not in pure space because it can
328;; be destructively mutated in lread.c:build_load_history.
329(setq load-history (mapcar 'purecopy load-history))
330(setq symbol-file-load-history-loaded t)
331
b7b75652 332(set-buffer-modified-p nil)
c2509060 333
ce87039d
SM
334;; reset the load-path. See lread.c:init_lread why.
335(if (or (equal (nth 3 command-line-args) "bootstrap")
336 (equal (nth 4 command-line-args) "bootstrap"))
337 (setcdr load-path nil))
338
0e328d37
SM
339(remove-hook 'after-load-functions '(lambda (f) (garbage-collect)))
340
8c766df1 341(setq inhibit-load-charset-map nil)
5bb65bd4 342(clear-charset-maps)
0d20f9a0
JB
343(garbage-collect)
344
0e328d37 345;; At this point, we're ready to resume undo recording for scratch.
ffd56f97
JB
346(buffer-enable-undo "*scratch*")
347
6a4803ec
RS
348(if (null (garbage-collect))
349 (setq pure-space-overflow t))
350
ce87039d
SM
351(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
352 (member (nth 4 command-line-args) '("dump" "bootstrap")))
7c2fb837 353 (progn
fc46d219
SM
354 (if (memq system-type '(ms-dos windows-nt cygwin))
355 (message "Dumping under the name emacs")
356 (message "Dumping under the name emacs"))
0d20f9a0 357 (condition-case ()
59f3e9a2 358 (delete-file "emacs")
0d20f9a0 359 (file-error nil))
59f3e9a2
JB
360 ;; We used to dump under the name xemacs, but that occasionally
361 ;; confused people installing Emacs (they'd install the file
362 ;; under the name `xemacs'), and it's inconsistent with every
0f4b266c 363 ;; other GNU program's build process.
59f3e9a2 364 (dump-emacs "emacs" "temacs")
4d337390 365 (message "%d pure bytes used" pure-bytes-used)
0d20f9a0 366 ;; Recompute NAME now, so that it isn't set when we dump.
fc46d219
SM
367 (if (not (or (memq system-type '(ms-dos windows-nt cygwin))
368 ;; Don't bother adding another name if we're just
369 ;; building bootstrap-emacs.
370 (equal (nth 3 command-line-args) "bootstrap")
371 (equal (nth 4 command-line-args) "bootstrap")))
ed10e0ab
RS
372 (let ((name (concat "emacs-" emacs-version)))
373 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
374 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
375 "-"
376 (substring name (match-end 0)))))
fc46d219 377 (message "Adding name %s" name)
ed10e0ab 378 (add-name-to-file "emacs" name t)))
0d20f9a0
JB
379 (kill-emacs)))
380
381;; Avoid error if user loads some more libraries now.
382(setq purify-flag nil)
383
384;; For machines with CANNOT_DUMP defined in config.h,
385;; this file must be loaded each time Emacs is run.
7fa26c0a 386;; So run the startup code now. First, remove `-l loadup' from args.
0d20f9a0 387
7fa26c0a
KH
388(if (and (equal (nth 1 command-line-args) "-l")
389 (equal (nth 2 command-line-args) "loadup"))
390 (setcdr command-line-args (nthcdr 3 command-line-args)))
391
392(eval top-level)
6594deb0 393
86db31d5 394\f
6e6c6aaf
SM
395;; Local Variables:
396;; no-byte-compile: t
397;; no-update-autoloads: t
398;; End:
6b61353c 399
6e6c6aaf 400;; arch-tag: 121e1dd4-36e1-45ac-860e-239f577a6335
6594deb0 401;;; loadup.el ends here