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