1 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
3 ;; Copyright (C) 1985-1986, 1992, 1994, 2001-2012
4 ;; Free Software Foundation, Inc.
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; This is loaded into a bare Emacs to make a dumpable one.
29 ;; If you add/remove Lisp files to be loaded here, consider the
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.
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:
40 ;; ii) If the file is loaded uncompiled, it should (where possible)
41 ;; obey the doc-string conventions expected by make-docfile.
45 ;; Add subdirectories to the load-path for files that might get
46 ;; autoloaded when bootstrapping.
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.
51 (if (or (equal (nth 3 command-line-args
) "bootstrap")
52 (equal (nth 4 command-line-args
) "bootstrap")
53 (equal (nth 3 command-line-args
) "unidata-gen.el")
54 (equal (nth 4 command-line-args
) "unidata-gen-files")
55 ;; In case CANNOT_DUMP.
56 (string-match "src/bootstrap-emacs" (nth 0 command-line-args
)))
57 (let ((dir (car load-path
)))
58 ;; We'll probably overflow the pure space.
59 (setq purify-flag nil
)
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
)))))
66 (if (eq t purify-flag
)
67 ;; Hash consing saved around 11% of pure space in my tests.
68 (setq purify-flag
(make-hash-table :test
'equal
:size
70000)))
70 (message "Using load-path %s" load-path
)
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
76 (setq inhibit-load-charset-map t
))
78 ;; We don't want to have any undo records in the dumped Emacs.
79 (set-buffer "*scratch*")
80 (setq buffer-undo-list t
)
82 (load "emacs-lisp/byte-run")
83 (load "emacs-lisp/backquote")
86 ;; Do it after subr, since both after-load-functions and add-hook are
87 ;; implemented in subr.el.
88 (add-hook 'after-load-functions
(lambda (f) (garbage-collect)))
94 (load "emacs-lisp/map-ynp")
95 (load "international/mule")
96 (load "international/mule-conf")
101 (load "window") ; Needed here for `replace-buffer-in-windows'.
102 (setq load-source-file-function
'load-with-code-conversion
)
106 (load "faces") ; after here, `defface' may be used.
112 ;; Don't get confused if someone compiled this by mistake.
114 ;; In case loaddefs hasn't been generated yet.
115 (file-error (load "ldefs-boot.el")))
118 (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
123 (load "jka-cmpr-hook")
125 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
126 ;; multilingual text.
127 (load "international/mule-cmds")
129 ;; This file doesn't exist when building a development version of Emacs
130 ;; from the repository. It is generated just after temacs is built.
131 (load "international/charprop.el" t
)
132 (load "international/characters")
135 ;; Load language-specific files.
136 (load "language/chinese")
137 (load "language/cyrillic")
138 (load "language/indian")
139 (load "language/sinhala")
140 (load "language/english")
141 (load "language/ethiopic")
142 (load "language/european")
143 (load "language/czech")
144 (load "language/slovak")
145 (load "language/romanian")
146 (load "language/greek")
147 (load "language/hebrew")
148 (load "language/japanese")
149 (load "language/korean")
150 (load "language/lao")
151 (load "language/tai-viet")
152 (load "language/thai")
153 (load "language/tibetan")
154 (load "language/vietnamese")
155 (load "language/misc-lang")
156 (load "language/utf-8-lang")
157 (load "language/georgian")
158 (load "language/khmer")
159 (load "language/burmese")
160 (load "language/cham")
164 (load "term/tty-colors")
166 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
167 ;; needs to be defined when font-lock is loaded.
169 (load "emacs-lisp/syntax")
173 (if (fboundp 'track-mouse
)
176 (and (boundp 'x-toolkit-scroll-bars
)
179 (load "emacs-lisp/timer")
184 (load "emacs-lisp/lisp")
185 (load "textmodes/page")
187 (load "textmodes/paragraphs")
188 (load "emacs-lisp/lisp-mode")
189 (load "textmodes/text-mode")
190 (load "textmodes/fill")
194 (load "emacs-lisp/tabulated-list")
197 (if (fboundp 'x-create-frame
)
200 ;; Needed by `imagemagick-register-types'
201 (load "emacs-lisp/regexp-opt")
203 (load "international/fontset")
207 (if (featurep 'dynamic-setting
)
208 (load "dynamic-setting"))
213 (load "term/common-win")
214 (load "term/x-win")))
216 (if (eq system-type
'windows-nt
)
219 (load "term/common-win")
220 (load "term/w32-win")
225 (if (eq system-type
'ms-dos
)
230 ;; Don't load term/common-win: it isn't appropriate for the `pc'
231 ;; ``window system'', which generally behaves like a terminal.
234 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
237 (load "term/common-win")
238 (load "term/ns-win")))
239 (if (fboundp 'x-create-frame
)
240 ;; Do it after loading term/foo-win.el since the value of the
241 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
243 ;; Preload some constants and floating point functions.
244 (load "emacs-lisp/float-sup")
247 (load "vc/ediff-hook")
248 (if (fboundp 'x-show-tip
) (load "tooltip"))
250 ;If you want additional libraries to be preloaded and their
251 ;doc strings kept in the DOC file rather than in core,
252 ;you may load them with a "site-load.el" file.
253 ;But you must also cause them to be scanned when the DOC file
255 ;For other systems, you must edit ../src/Makefile.in.
258 ;; ¡¡¡ Big Ugly Hack !!!
259 ;; src/bootstrap-emacs is mostly used to compile .el files, so it needs
260 ;; macroexp, bytecomp, cconv, and byte-opt to be fast. Generally this is done
261 ;; by compiling those files first, but this only makes a difference if those
262 ;; files are not preloaded. As it so happens, macroexp.el tends to be
263 ;; accidentally preloaded in src/bootstrap-emacs because cl.el and cl-macs.el
264 ;; require it. So let's unload it here, if needed, to make sure the
265 ;; byte-compiled version is used.
266 (if (or (not (fboundp 'macroexpand-all
))
267 (byte-code-function-p (symbol-function 'macroexpand-all
)))
269 (fmakunbound 'macroexpand-all
)
270 (setq features
(delq 'macroexp features
))
271 (autoload 'macroexpand-all
"macroexp"))
273 ;; Determine which last version number to use
274 ;; based on the executables that now exist.
275 (if (and (or (equal (nth 3 command-line-args
) "dump")
276 (equal (nth 4 command-line-args
) "dump"))
277 (not (eq system-type
'ms-dos
)))
278 (let* ((base (concat "emacs-" emacs-version
"."))
279 (files (file-name-all-completions base default-directory
))
280 (versions (mapcar (function (lambda (name)
281 (string-to-number (substring name
(length base
)))))
283 (setq emacs-bzr-version
(condition-case nil
(emacs-bzr-get-version)
285 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
286 (defconst emacs-version
288 emacs-version
(if versions
(1+ (apply 'max versions
)) 1)))))
291 (message "Finding pointers to doc strings...")
292 (if (or (equal (nth 3 command-line-args
) "dump")
293 (equal (nth 4 command-line-args
) "dump"))
294 (let ((name emacs-version
))
295 (while (string-match "[^-+_.a-zA-Z0-9]+" name
)
296 (setq name
(concat (downcase (substring name
0 (match-beginning 0)))
298 (substring name
(match-end 0)))))
299 (if (memq system-type
'(ms-dos windows-nt
))
300 (setq name
(expand-file-name
301 (if (fboundp 'x-create-frame
) "DOC-X" "DOC") "../etc"))
302 (setq name
(concat (expand-file-name "../etc/DOC-") name
))
303 (if (file-exists-p name
)
305 (copy-file (expand-file-name "../etc/DOC") name t
))
306 (Snarf-documentation (file-name-nondirectory name
)))
308 (Snarf-documentation "DOC")
310 (message "Finding pointers to doc strings...done")
312 ;; Note: You can cause additional libraries to be preloaded
313 ;; by writing a site-init.el that loads them.
314 ;; See also "site-load" above.
316 (setq current-load-list nil
)
318 ;; We keep the load-history data in PURE space.
319 ;; Make sure that the spine of the list is not in pure space because it can
320 ;; be destructively mutated in lread.c:build_load_history.
321 (setq load-history
(mapcar 'purecopy load-history
))
323 (set-buffer-modified-p nil
)
325 ;; reset the load-path. See lread.c:init_lread why.
326 (if (or (equal (nth 3 command-line-args
) "bootstrap")
327 (equal (nth 4 command-line-args
) "bootstrap"))
328 (setcdr load-path nil
))
330 (remove-hook 'after-load-functions
(lambda (f) (garbage-collect)))
332 (setq inhibit-load-charset-map nil
)
336 ;; At this point, we're ready to resume undo recording for scratch.
337 (buffer-enable-undo "*scratch*")
339 (when (hash-table-p purify-flag
)
345 (maphash (lambda (k v
)
347 ((stringp k
) (setq strings
(1+ strings
)))
348 ((vectorp k
) (setq vectors
(1+ vectors
)))
349 ((consp k
) (setq conses
(1+ conses
)))
350 ((byte-code-function-p v
) (setq bytecodes
(1+ bytecodes
)))
351 (t (setq others
(1+ others
)))))
353 (message "Pure-hashed: %d strings, %d vectors, %d conses, %d bytecodes, %d others"
354 strings vectors conses bytecodes others
)))
356 ;; Avoid error if user loads some more libraries now and make sure the
357 ;; hash-consing hash table is GC'd.
358 (setq purify-flag nil
)
360 (if (null (garbage-collect))
361 (setq pure-space-overflow t
))
363 (if (or (member (nth 3 command-line-args
) '("dump" "bootstrap"))
364 (member (nth 4 command-line-args
) '("dump" "bootstrap")))
366 (if (memq system-type
'(ms-dos windows-nt cygwin
))
367 (message "Dumping under the name emacs")
368 (message "Dumping under the name emacs"))
370 (delete-file "emacs")
372 ;; We used to dump under the name xemacs, but that occasionally
373 ;; confused people installing Emacs (they'd install the file
374 ;; under the name `xemacs'), and it's inconsistent with every
375 ;; other GNU program's build process.
376 (dump-emacs "emacs" "temacs")
377 (message "%d pure bytes used" pure-bytes-used
)
378 ;; Recompute NAME now, so that it isn't set when we dump.
379 (if (not (or (memq system-type
'(ms-dos windows-nt
))
380 ;; Don't bother adding another name if we're just
381 ;; building bootstrap-emacs.
382 (equal (nth 3 command-line-args
) "bootstrap")
383 (equal (nth 4 command-line-args
) "bootstrap")))
384 (let ((name (concat "emacs-" emacs-version
)))
385 (while (string-match "[^-+_.a-zA-Z0-9]+" name
)
386 (setq name
(concat (downcase (substring name
0 (match-beginning 0)))
388 (substring name
(match-end 0)))))
389 (message "Adding name %s" name
)
390 (add-name-to-file "emacs" name t
)))
393 ;; For machines with CANNOT_DUMP defined in config.h,
394 ;; this file must be loaded each time Emacs is run.
395 ;; So run the startup code now. First, remove `-l loadup' from args.
397 (if (and (equal (nth 1 command-line-args
) "-l")
398 (equal (nth 2 command-line-args
) "loadup"))
399 (setcdr command-line-args
(nthcdr 3 command-line-args
)))
405 ;; no-byte-compile: t
406 ;; no-update-autoloads: t
409 ;;; loadup.el ends here