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