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