]> code.delx.au - gnu-emacs/blob - lisp/loadup.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / loadup.el
1 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
2
3 ;; Copyright (C) 1985-1986, 1992, 1994, 2001-2011 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: internal
7 ;; Package: emacs
8
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
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) 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
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; This is loaded into a bare Emacs to make a dumpable one.
27
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
48 ;;; Code:
49
50 ;; Add subdirectories to the load-path for files that might get
51 ;; autoloaded when bootstrapping.
52 (if (or (equal (nth 3 command-line-args) "bootstrap")
53 (equal (nth 4 command-line-args) "bootstrap")
54 (equal (nth 3 command-line-args) "unidata-gen.el")
55 (equal (nth 4 command-line-args) "unidata-gen-files")
56 ;; In case CANNOT_DUMP.
57 (string-match "src/bootstrap-emacs" (nth 0 command-line-args)))
58 (let ((dir (car load-path)))
59 ;; We'll probably overflow the pure space.
60 (setq purify-flag nil)
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)))))
66
67 (if (eq t purify-flag)
68 ;; Hash consing saved around 11% of pure space in my tests.
69 (setq purify-flag (make-hash-table :test 'equal)))
70
71 (message "Using load-path %s" load-path)
72
73 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
74 (member (nth 4 command-line-args) '("dump" "bootstrap")))
75 ;; To reduce the size of dumped Emacs, we avoid making huge
76 ;; char-tables.
77 (setq inhibit-load-charset-map t))
78
79 ;; We don't want to have any undo records in the dumped Emacs.
80 (set-buffer "*scratch*")
81 (setq buffer-undo-list t)
82
83 (load "emacs-lisp/byte-run")
84 (load "emacs-lisp/backquote")
85 (load "subr")
86
87 ;; Do it after subr, since both after-load-functions and add-hook are
88 ;; implemented in subr.el.
89 (add-hook 'after-load-functions '(lambda (f) (garbage-collect)))
90
91 ;; We specify .el in case someone compiled version.el by mistake.
92 (load "version.el")
93
94 (load "widget")
95 (load "custom")
96 (load "emacs-lisp/map-ynp")
97 (load "cus-start")
98 (load "international/mule")
99 (load "international/mule-conf")
100 (load "env")
101 (load "format")
102 (load "bindings")
103 (setq load-source-file-function 'load-with-code-conversion)
104 (load "files")
105
106 (load "cus-face")
107 (load "faces") ; after here, `defface' may be used.
108 (load "minibuffer")
109
110 (load "button")
111 (load "startup")
112
113 (condition-case nil
114 ;; Don't get confused if someone compiled this by mistake.
115 (load "loaddefs.el")
116 ;; In case loaddefs hasn't been generated yet.
117 (file-error (load "ldefs-boot.el")))
118
119 (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
120 (load "simple")
121
122 (load "help")
123
124 (load "jka-cmpr-hook")
125 (load "epa-hook")
126 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
127 ;; multilingual text.
128 (load "international/mule-cmds")
129 (load "case-table")
130 (load "international/characters")
131 (load "composite")
132 ;; This file doesn't exist when building a development version of Emacs
133 ;; from the repository. It is generated just after temacs is built.
134 (load "international/charprop.el" t)
135
136 ;; Load language-specific files.
137 (load "language/chinese")
138 (load "language/cyrillic")
139 (load "language/indian")
140 (load "language/sinhala")
141 (load "language/english")
142 (load "language/ethiopic")
143 (load "language/european")
144 (load "language/czech")
145 (load "language/slovak")
146 (load "language/romanian")
147 (load "language/greek")
148 (load "language/hebrew")
149 (load "language/japanese")
150 (load "language/korean")
151 (load "language/lao")
152 (load "language/tai-viet")
153 (load "language/thai")
154 (load "language/tibetan")
155 (load "language/vietnamese")
156 (load "language/misc-lang")
157 (load "language/utf-8-lang")
158 (load "language/georgian")
159 (load "language/khmer")
160 (load "language/burmese")
161 (load "language/cham")
162
163 (load "indent")
164 (load "window")
165 (load "frame")
166 (load "term/tty-colors")
167 (load "font-core")
168 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
169 ;; needs to be defined when font-lock is loaded.
170 (load "facemenu")
171 (load "emacs-lisp/syntax")
172 (load "font-lock")
173 (load "jit-lock")
174
175 (if (fboundp 'track-mouse)
176 (progn
177 (load "mouse")
178 (and (boundp 'x-toolkit-scroll-bars)
179 (load "scroll-bar"))
180 (load "select")))
181 (load "emacs-lisp/timer")
182 (load "isearch")
183 (load "rfn-eshadow")
184
185 (load "menu-bar")
186 (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
187 (load "emacs-lisp/lisp")
188 (load "textmodes/page")
189 (load "register")
190 (load "textmodes/paragraphs")
191 (load "emacs-lisp/lisp-mode")
192 (load "textmodes/text-mode")
193 (load "textmodes/fill")
194
195 (load "replace")
196 (load "buff-menu")
197
198 (if (fboundp 'x-create-frame)
199 (progn
200 (load "fringe")
201 (load "image")
202 (load "international/fontset")
203 (load "dnd")
204 (load "tool-bar")))
205
206 (if (featurep 'dynamic-setting)
207 (load "dynamic-setting"))
208
209 (if (featurep 'x)
210 (progn
211 (load "x-dnd")
212 (load "term/common-win")
213 (load "term/x-win")))
214
215 (if (eq system-type 'windows-nt)
216 (progn
217 (load "w32-vars")
218 (load "term/common-win")
219 (load "term/w32-win")
220 (load "ls-lisp")
221 (load "disp-table")
222 (load "dos-w32")
223 (load "w32-fns")))
224 (if (eq system-type 'ms-dos)
225 (progn
226 (load "dos-w32")
227 (load "dos-fns")
228 (load "dos-vars")
229 ;; Don't load term/common-win: it isn't appropriate for the `pc'
230 ;; ``window system'', which generally behaves like a terminal.
231 (load "term/pc-win")
232 (load "ls-lisp")
233 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
234 (if (featurep 'ns)
235 (progn
236 (load "term/common-win")
237 (load "term/ns-win")))
238 (if (fboundp 'x-create-frame)
239 ;; Do it after loading term/foo-win.el since the value of the
240 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
241 (load "mwheel"))
242 ;; Preload some constants and floating point functions.
243 (load "emacs-lisp/float-sup")
244
245 (load "vc/vc-hooks")
246 (load "vc/ediff-hook")
247 (if (fboundp 'x-show-tip) (load "tooltip"))
248
249 ;If you want additional libraries to be preloaded and their
250 ;doc strings kept in the DOC file rather than in core,
251 ;you may load them with a "site-load.el" file.
252 ;But you must also cause them to be scanned when the DOC file
253 ;is generated.
254 ;For other systems, you must edit ../src/Makefile.in.
255 (load "site-load" t)
256
257 ;; Determine which last version number to use
258 ;; based on the executables that now exist.
259 (if (and (or (equal (nth 3 command-line-args) "dump")
260 (equal (nth 4 command-line-args) "dump"))
261 (not (eq system-type 'ms-dos)))
262 (let* ((base (concat "emacs-" emacs-version "."))
263 (files (file-name-all-completions base default-directory))
264 (versions (mapcar (function (lambda (name)
265 (string-to-int (substring name (length base)))))
266 files)))
267 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
268 (defconst emacs-version
269 (format "%s.%d"
270 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
271
272
273 (message "Finding pointers to doc strings...")
274 (if (or (equal (nth 3 command-line-args) "dump")
275 (equal (nth 4 command-line-args) "dump"))
276 (let ((name emacs-version))
277 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
278 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
279 "-"
280 (substring name (match-end 0)))))
281 (if (memq system-type '(ms-dos windows-nt))
282 (setq name (expand-file-name
283 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
284 (setq name (concat (expand-file-name "../etc/DOC-") name))
285 (if (file-exists-p name)
286 (delete-file name))
287 (copy-file (expand-file-name "../etc/DOC") name t))
288 (Snarf-documentation (file-name-nondirectory name)))
289 (condition-case nil
290 (Snarf-documentation "DOC")
291 (error nil)))
292 (message "Finding pointers to doc strings...done")
293
294 ;; Note: You can cause additional libraries to be preloaded
295 ;; by writing a site-init.el that loads them.
296 ;; See also "site-load" above.
297 (load "site-init" t)
298 (setq current-load-list nil)
299
300 ;; We keep the load-history data in PURE space.
301 ;; Make sure that the spine of the list is not in pure space because it can
302 ;; be destructively mutated in lread.c:build_load_history.
303 (setq load-history (mapcar 'purecopy load-history))
304
305 (set-buffer-modified-p nil)
306
307 ;; reset the load-path. See lread.c:init_lread why.
308 (if (or (equal (nth 3 command-line-args) "bootstrap")
309 (equal (nth 4 command-line-args) "bootstrap"))
310 (setcdr load-path nil))
311
312 (remove-hook 'after-load-functions '(lambda (f) (garbage-collect)))
313
314 (setq inhibit-load-charset-map nil)
315 (clear-charset-maps)
316 (garbage-collect)
317
318 ;; At this point, we're ready to resume undo recording for scratch.
319 (buffer-enable-undo "*scratch*")
320
321 ;; Avoid error if user loads some more libraries now and make sure the
322 ;; hash-consing hash table is GC'd.
323 (setq purify-flag nil)
324
325 (if (null (garbage-collect))
326 (setq pure-space-overflow t))
327
328 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
329 (member (nth 4 command-line-args) '("dump" "bootstrap")))
330 (progn
331 (if (memq system-type '(ms-dos windows-nt cygwin))
332 (message "Dumping under the name emacs")
333 (message "Dumping under the name emacs"))
334 (condition-case ()
335 (delete-file "emacs")
336 (file-error nil))
337 ;; We used to dump under the name xemacs, but that occasionally
338 ;; confused people installing Emacs (they'd install the file
339 ;; under the name `xemacs'), and it's inconsistent with every
340 ;; other GNU program's build process.
341 (dump-emacs "emacs" "temacs")
342 (message "%d pure bytes used" pure-bytes-used)
343 ;; Recompute NAME now, so that it isn't set when we dump.
344 (if (not (or (memq system-type '(ms-dos windows-nt))
345 ;; Don't bother adding another name if we're just
346 ;; building bootstrap-emacs.
347 (equal (nth 3 command-line-args) "bootstrap")
348 (equal (nth 4 command-line-args) "bootstrap")))
349 (let ((name (concat "emacs-" emacs-version)))
350 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
351 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
352 "-"
353 (substring name (match-end 0)))))
354 (message "Adding name %s" name)
355 (add-name-to-file "emacs" name t)))
356 (kill-emacs)))
357
358 ;; For machines with CANNOT_DUMP defined in config.h,
359 ;; this file must be loaded each time Emacs is run.
360 ;; So run the startup code now. First, remove `-l loadup' from args.
361
362 (if (and (equal (nth 1 command-line-args) "-l")
363 (equal (nth 2 command-line-args) "loadup"))
364 (setcdr command-line-args (nthcdr 3 command-line-args)))
365
366 (eval top-level)
367
368 \f
369 ;; Local Variables:
370 ;; no-byte-compile: t
371 ;; no-update-autoloads: t
372 ;; End:
373
374 ;;; loadup.el ends here