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