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