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