]> code.delx.au - gnu-emacs/blob - lisp/loadup.el
(tooltip-frame-parameters): Undo previous change.
[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, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5
6 ;; Maintainer: FSF
7 ;; Keywords: internal
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 (equal (nth 0 command-line-args) "../src/bootstrap-emacs"))
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 (message "Using load-path %s" load-path)
68
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
75 ;; We don't want to have any undo records in the dumped Emacs.
76 (set-buffer "*scratch*")
77 (setq buffer-undo-list t)
78
79 (load "emacs-lisp/byte-run")
80 (load "emacs-lisp/backquote")
81 (load "subr")
82
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
87 ;; We specify .el in case someone compiled version.el by mistake.
88 (load "version.el")
89
90 (load "widget")
91 (load "custom")
92 (load "emacs-lisp/map-ynp")
93 (load "cus-start")
94 (load "international/mule")
95 (load "international/mule-conf")
96 (load "env")
97 (load "format")
98 (load "bindings")
99 (setq load-source-file-function 'load-with-code-conversion)
100 (load "files")
101
102 (load "cus-face")
103 (load "faces") ; after here, `defface' may be used.
104 (load "minibuffer")
105
106 (load "button")
107 (load "startup")
108
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
115 (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
116 (load "simple")
117
118 (load "help")
119
120 (load "jka-cmpr-hook")
121 (load "epa-hook")
122 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
123 ;; multilingual text.
124 (load "international/mule-cmds")
125 (load "case-table")
126 (load "international/characters")
127 (load "composite")
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)
131
132 ;; Load language-specific files.
133 (load "language/chinese")
134 (load "language/cyrillic")
135 (load "language/indian")
136 (load "language/sinhala")
137 (load "language/english")
138 (load "language/ethiopic")
139 (load "language/european")
140 (load "language/czech")
141 (load "language/slovak")
142 (load "language/romanian")
143 (load "language/greek")
144 (load "language/hebrew")
145 (load "language/japanese")
146 (load "language/korean")
147 (load "language/lao")
148 (load "language/tai-viet")
149 (load "language/thai")
150 (load "language/tibetan")
151 (load "language/vietnamese")
152 (load "language/misc-lang")
153 (load "language/utf-8-lang")
154 (load "language/georgian")
155 (load "language/khmer")
156 (load "language/burmese")
157 (load "language/cham")
158
159 (load "indent")
160 (load "window")
161 (load "frame")
162 (load "term/tty-colors")
163 (load "font-core")
164 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
165 ;; needs to be defined when font-lock is loaded.
166 (load "facemenu")
167 (load "emacs-lisp/syntax")
168 (load "font-lock")
169 (load "jit-lock")
170
171 (if (fboundp 'track-mouse)
172 (progn
173 (load "mouse")
174 (and (boundp 'x-toolkit-scroll-bars)
175 (load "scroll-bar"))
176 (load "select")))
177 (load "emacs-lisp/timer")
178 (load "isearch")
179 (load "rfn-eshadow")
180
181 (load "menu-bar")
182 (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
183 (load "emacs-lisp/lisp")
184 (load "textmodes/page")
185 (load "register")
186 (load "textmodes/paragraphs")
187 (load "emacs-lisp/lisp-mode")
188 (load "textmodes/text-mode")
189 (load "textmodes/fill")
190
191 (load "replace")
192 (load "buff-menu")
193
194 (if (fboundp 'x-create-frame)
195 (progn
196 (load "fringe")
197 (load "image")
198 (load "international/fontset")
199 (load "dnd")
200 (load "tool-bar")))
201 (if (featurep 'x)
202 (progn
203 (load "x-dnd")
204 (load "term/common-win")
205 (load "term/x-win")))
206
207 (if (eq system-type 'windows-nt)
208 (progn
209 (load "w32-vars")
210 (load "term/common-win")
211 (load "term/w32-win")
212 (load "ls-lisp")
213 (load "disp-table")
214 (load "dos-w32")
215 (load "w32-fns")))
216 (if (eq system-type 'ms-dos)
217 (progn
218 (load "dos-w32")
219 (load "dos-fns")
220 (load "dos-vars")
221 ;; Don't load term/common-win: it isn't appropriate for the `pc'
222 ;; ``window system'', which generally behaves like a terminal.
223 (load "term/pc-win")
224 (load "ls-lisp")
225 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
226 (if (featurep 'ns)
227 (progn
228 (load "emacs-lisp/easymenu") ;; for platform-related menu adjustments
229 (load "term/ns-win")))
230 (if (fboundp 'x-create-frame)
231 ;; Do it after loading term/foo-win.el since the value of the
232 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
233 (load "mwheel"))
234 (if (fboundp 'atan) ; preload some constants and
235 (progn ; floating pt. functions if we have float support.
236 (load "emacs-lisp/float-sup")))
237
238 (load "vc-hooks")
239 (load "ediff-hook")
240 (if (fboundp 'x-show-tip) (load "tooltip"))
241
242 ;If you want additional libraries to be preloaded and their
243 ;doc strings kept in the DOC file rather than in core,
244 ;you may load them with a "site-load.el" file.
245 ;But you must also cause them to be scanned when the DOC file
246 ;is generated.
247 ;For other systems, you must edit ../src/Makefile.in.
248 (load "site-load" t)
249
250 ;; Determine which last version number to use
251 ;; based on the executables that now exist.
252 (if (and (or (equal (nth 3 command-line-args) "dump")
253 (equal (nth 4 command-line-args) "dump"))
254 (not (eq system-type 'ms-dos)))
255 (let* ((base (concat "emacs-" emacs-version "."))
256 (files (file-name-all-completions base default-directory))
257 (versions (mapcar (function (lambda (name)
258 (string-to-int (substring name (length base)))))
259 files)))
260 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
261 (defconst emacs-version
262 (format "%s.%d"
263 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
264
265
266 (message "Finding pointers to doc strings...")
267 (if (or (equal (nth 3 command-line-args) "dump")
268 (equal (nth 4 command-line-args) "dump"))
269 (let ((name emacs-version))
270 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
271 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
272 "-"
273 (substring name (match-end 0)))))
274 (if (memq system-type '(ms-dos windows-nt))
275 (setq name (expand-file-name
276 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
277 (setq name (concat (expand-file-name "../etc/DOC-") name))
278 (if (file-exists-p name)
279 (delete-file name))
280 (copy-file (expand-file-name "../etc/DOC") name t))
281 (Snarf-documentation (file-name-nondirectory name)))
282 (condition-case nil
283 (Snarf-documentation "DOC")
284 (error nil)))
285 (message "Finding pointers to doc strings...done")
286
287 ;;;Note: You can cause additional libraries to be preloaded
288 ;;;by writing a site-init.el that loads them.
289 ;;;See also "site-load" above.
290 (load "site-init" t)
291 (setq current-load-list nil)
292
293 ;; Write the value of load-history into fns-VERSION.el,
294 ;; then clear out load-history.
295 ;; (if (or (equal (nth 3 command-line-args) "dump")
296 ;; (equal (nth 4 command-line-args) "dump"))
297 ;; (let ((buffer-undo-list t))
298 ;; (princ "(setq load-history\n" (current-buffer))
299 ;; (princ " (nconc load-history\n" (current-buffer))
300 ;; (princ " '(" (current-buffer))
301 ;; (let ((tem load-history))
302 ;; (while tem
303 ;; (prin1 (car tem) (current-buffer))
304 ;; (terpri (current-buffer))
305 ;; (if (cdr tem)
306 ;; (princ " " (current-buffer)))
307 ;; (setq tem (cdr tem))))
308 ;; (princ ")))\n" (current-buffer))
309 ;; (write-region (point-min) (point-max)
310 ;; (expand-file-name
311 ;; (cond
312 ;; ((eq system-type 'ms-dos)
313 ;; "../lib-src/fns.el")
314 ;; ((eq system-type 'windows-nt)
315 ;; (format "../../../lib-src/fns-%s.el" emacs-version))
316 ;; (t
317 ;; (format "../lib-src/fns-%s.el" emacs-version)))
318 ;; invocation-directory))
319 ;; (erase-buffer)
320 ;; (setq load-history nil))
321 ;; (setq symbol-file-load-history-loaded t))
322 ;; We don't use this fns-*.el file. Instead we keep the data in PURE space.
323 ;; Make sure that the spine of the list is not in pure space because it can
324 ;; be destructively mutated in lread.c:build_load_history.
325 (setq load-history (mapcar 'purecopy load-history))
326 (setq symbol-file-load-history-loaded t)
327
328 (set-buffer-modified-p nil)
329
330 ;; reset the load-path. See lread.c:init_lread why.
331 (if (or (equal (nth 3 command-line-args) "bootstrap")
332 (equal (nth 4 command-line-args) "bootstrap"))
333 (setcdr load-path nil))
334
335 (remove-hook 'after-load-functions '(lambda (f) (garbage-collect)))
336
337 (setq inhibit-load-charset-map nil)
338 (clear-charset-maps)
339 (garbage-collect)
340
341 ;; At this point, we're ready to resume undo recording for scratch.
342 (buffer-enable-undo "*scratch*")
343
344 (if (null (garbage-collect))
345 (setq pure-space-overflow t))
346
347 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
348 (member (nth 4 command-line-args) '("dump" "bootstrap")))
349 (progn
350 (if (memq system-type '(ms-dos windows-nt cygwin))
351 (message "Dumping under the name emacs")
352 (message "Dumping under the name emacs"))
353 (condition-case ()
354 (delete-file "emacs")
355 (file-error nil))
356 ;; We used to dump under the name xemacs, but that occasionally
357 ;; confused people installing Emacs (they'd install the file
358 ;; under the name `xemacs'), and it's inconsistent with every
359 ;; other GNU program's build process.
360 (dump-emacs "emacs" "temacs")
361 (message "%d pure bytes used" pure-bytes-used)
362 ;; Recompute NAME now, so that it isn't set when we dump.
363 (if (not (or (memq system-type '(ms-dos windows-nt cygwin))
364 ;; Don't bother adding another name if we're just
365 ;; building bootstrap-emacs.
366 (equal (nth 3 command-line-args) "bootstrap")
367 (equal (nth 4 command-line-args) "bootstrap")))
368 (let ((name (concat "emacs-" emacs-version)))
369 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
370 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
371 "-"
372 (substring name (match-end 0)))))
373 (message "Adding name %s" name)
374 (add-name-to-file "emacs" name t)))
375 (kill-emacs)))
376
377 ;; Avoid error if user loads some more libraries now.
378 (setq purify-flag nil)
379
380 ;; For machines with CANNOT_DUMP defined in config.h,
381 ;; this file must be loaded each time Emacs is run.
382 ;; So run the startup code now. First, remove `-l loadup' from args.
383
384 (if (and (equal (nth 1 command-line-args) "-l")
385 (equal (nth 2 command-line-args) "loadup"))
386 (setcdr command-line-args (nthcdr 3 command-line-args)))
387
388 (eval top-level)
389
390 \f
391 ;; Local Variables:
392 ;; no-byte-compile: t
393 ;; no-update-autoloads: t
394 ;; End:
395
396 ;; arch-tag: 121e1dd4-36e1-45ac-860e-239f577a6335
397 ;;; loadup.el ends here