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