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