Add "Package:" file headers to denote built-in packages.
[emacs.git] / lisp / loadup.el
blob7757a0e5b40db4d12a81dd8e112d700d0c1e03fc
1 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: internal
8 ;; Package: emacs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; This is loaded into a bare Emacs to make a dumpable one.
29 ;; If you add/remove Lisp files to be loaded here, consider the
30 ;; following issues:
32 ;; i) Any file loaded on all platforms should appear in $lisp
33 ;; and $shortlisp in src/Makefile.in. Use the .el or .elc version as
34 ;; appropriate.
36 ;; ii) Any file that is only loaded on some platforms should appear
37 ;; in the version of $lisp in the generated Makefile on that platform.
38 ;; At the present time, this is achieved by use of #ifdefs.
39 ;; It should also appear in $SOME_MACHINE_LISP on all platforms.
41 ;; The above steps ensure both that the Lisp files are compiled (if
42 ;; necessary) before the emacs executable is dumped, and that they are
43 ;; passed to make-docfile. (Any that are not processed for DOC will
44 ;; not have doc strings in the dumped Emacs.) Because of this:
46 ;; iii) If the file is loaded uncompiled, it should (where possible)
47 ;; obey the doc-string conventions expected by make-docfile.
49 ;;; Code:
51 ;; Add subdirectories to the load-path for files that might get
52 ;; autoloaded when bootstrapping.
53 (if (or (equal (nth 3 command-line-args) "bootstrap")
54 (equal (nth 4 command-line-args) "bootstrap")
55 (equal (nth 3 command-line-args) "unidata-gen.el")
56 (equal (nth 4 command-line-args) "unidata-gen-files")
57 ;; In case CANNOT_DUMP.
58 (string-match "src/bootstrap-emacs" (nth 0 command-line-args)))
59 (let ((dir (car load-path)))
60 ;; We'll probably overflow the pure space.
61 (setq purify-flag nil)
62 (setq load-path (list dir
63 (expand-file-name "emacs-lisp" dir)
64 (expand-file-name "language" dir)
65 (expand-file-name "international" dir)
66 (expand-file-name "textmodes" dir)))))
68 (if (eq t purify-flag)
69 ;; Hash consing saved around 11% of pure space in my tests.
70 (setq purify-flag (make-hash-table :test 'equal)))
72 (message "Using load-path %s" load-path)
74 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
75 (member (nth 4 command-line-args) '("dump" "bootstrap")))
76 ;; To reduce the size of dumped Emacs, we avoid making huge
77 ;; char-tables.
78 (setq inhibit-load-charset-map t))
80 ;; We don't want to have any undo records in the dumped Emacs.
81 (set-buffer "*scratch*")
82 (setq buffer-undo-list t)
84 (load "emacs-lisp/byte-run")
85 (load "emacs-lisp/backquote")
86 (load "subr")
88 ;; Do it after subr, since both after-load-functions and add-hook are
89 ;; implemented in subr.el.
90 (add-hook 'after-load-functions '(lambda (f) (garbage-collect)))
92 ;; We specify .el in case someone compiled version.el by mistake.
93 (load "version.el")
95 (load "widget")
96 (load "custom")
97 (load "emacs-lisp/map-ynp")
98 (load "cus-start")
99 (load "international/mule")
100 (load "international/mule-conf")
101 (load "env")
102 (load "format")
103 (load "bindings")
104 (setq load-source-file-function 'load-with-code-conversion)
105 (load "files")
107 (load "cus-face")
108 (load "faces") ; after here, `defface' may be used.
109 (load "minibuffer")
111 (load "button")
112 (load "startup")
114 (condition-case nil
115 ;; Don't get confused if someone compiled this by mistake.
116 (load "loaddefs.el")
117 ;; In case loaddefs hasn't been generated yet.
118 (file-error (load "ldefs-boot.el")))
120 (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
121 (load "simple")
123 (load "help")
125 (load "jka-cmpr-hook")
126 (load "epa-hook")
127 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
128 ;; multilingual text.
129 (load "international/mule-cmds")
130 (load "case-table")
131 (load "international/characters")
132 (load "composite")
133 ;; This file doesn't exist when building a development version of Emacs
134 ;; from the repository. It is generated just after temacs is built.
135 (load "international/charprop.el" t)
137 ;; Load language-specific files.
138 (load "language/chinese")
139 (load "language/cyrillic")
140 (load "language/indian")
141 (load "language/sinhala")
142 (load "language/english")
143 (load "language/ethiopic")
144 (load "language/european")
145 (load "language/czech")
146 (load "language/slovak")
147 (load "language/romanian")
148 (load "language/greek")
149 (load "language/hebrew")
150 (load "language/japanese")
151 (load "language/korean")
152 (load "language/lao")
153 (load "language/tai-viet")
154 (load "language/thai")
155 (load "language/tibetan")
156 (load "language/vietnamese")
157 (load "language/misc-lang")
158 (load "language/utf-8-lang")
159 (load "language/georgian")
160 (load "language/khmer")
161 (load "language/burmese")
162 (load "language/cham")
164 (load "indent")
165 (load "window")
166 (load "frame")
167 (load "term/tty-colors")
168 (load "font-core")
169 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
170 ;; needs to be defined when font-lock is loaded.
171 (load "facemenu")
172 (load "emacs-lisp/syntax")
173 (load "font-lock")
174 (load "jit-lock")
176 (if (fboundp 'track-mouse)
177 (progn
178 (load "mouse")
179 (and (boundp 'x-toolkit-scroll-bars)
180 (load "scroll-bar"))
181 (load "select")))
182 (load "emacs-lisp/timer")
183 (load "isearch")
184 (load "rfn-eshadow")
186 (load "menu-bar")
187 (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
188 (load "emacs-lisp/lisp")
189 (load "textmodes/page")
190 (load "register")
191 (load "textmodes/paragraphs")
192 (load "emacs-lisp/lisp-mode")
193 (load "textmodes/text-mode")
194 (load "textmodes/fill")
196 (load "replace")
197 (load "buff-menu")
199 (if (fboundp 'x-create-frame)
200 (progn
201 (load "fringe")
202 (load "image")
203 (load "international/fontset")
204 (load "dnd")
205 (load "tool-bar")))
207 (if (featurep 'dynamic-setting)
208 (load "dynamic-setting"))
210 (if (featurep 'x)
211 (progn
212 (load "x-dnd")
213 (load "term/common-win")
214 (load "term/x-win")))
216 (if (eq system-type 'windows-nt)
217 (progn
218 (load "w32-vars")
219 (load "term/common-win")
220 (load "term/w32-win")
221 (load "ls-lisp")
222 (load "disp-table")
223 (load "dos-w32")
224 (load "w32-fns")))
225 (if (eq system-type 'ms-dos)
226 (progn
227 (load "dos-w32")
228 (load "dos-fns")
229 (load "dos-vars")
230 ;; Don't load term/common-win: it isn't appropriate for the `pc'
231 ;; ``window system'', which generally behaves like a terminal.
232 (load "term/pc-win")
233 (load "ls-lisp")
234 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
235 (if (featurep 'ns)
236 (progn
237 (load "emacs-lisp/easymenu") ;; for platform-related menu adjustments
238 (load "term/ns-win")))
239 (if (fboundp 'x-create-frame)
240 ;; Do it after loading term/foo-win.el since the value of the
241 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
242 (load "mwheel"))
243 (if (fboundp 'atan) ; preload some constants and
244 (progn ; floating pt. functions if we have float support.
245 (load "emacs-lisp/float-sup")))
247 (load "vc/vc-hooks")
248 (load "vc/ediff-hook")
249 (if (fboundp 'x-show-tip) (load "tooltip"))
251 ;If you want additional libraries to be preloaded and their
252 ;doc strings kept in the DOC file rather than in core,
253 ;you may load them with a "site-load.el" file.
254 ;But you must also cause them to be scanned when the DOC file
255 ;is generated.
256 ;For other systems, you must edit ../src/Makefile.in.
257 (load "site-load" t)
259 ;; Determine which last version number to use
260 ;; based on the executables that now exist.
261 (if (and (or (equal (nth 3 command-line-args) "dump")
262 (equal (nth 4 command-line-args) "dump"))
263 (not (eq system-type 'ms-dos)))
264 (let* ((base (concat "emacs-" emacs-version "."))
265 (files (file-name-all-completions base default-directory))
266 (versions (mapcar (function (lambda (name)
267 (string-to-int (substring name (length base)))))
268 files)))
269 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
270 (defconst emacs-version
271 (format "%s.%d"
272 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
275 (message "Finding pointers to doc strings...")
276 (if (or (equal (nth 3 command-line-args) "dump")
277 (equal (nth 4 command-line-args) "dump"))
278 (let ((name emacs-version))
279 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
280 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
282 (substring name (match-end 0)))))
283 (if (memq system-type '(ms-dos windows-nt))
284 (setq name (expand-file-name
285 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
286 (setq name (concat (expand-file-name "../etc/DOC-") name))
287 (if (file-exists-p name)
288 (delete-file name))
289 (copy-file (expand-file-name "../etc/DOC") name t))
290 (Snarf-documentation (file-name-nondirectory name)))
291 (condition-case nil
292 (Snarf-documentation "DOC")
293 (error nil)))
294 (message "Finding pointers to doc strings...done")
296 ;;;Note: You can cause additional libraries to be preloaded
297 ;;;by writing a site-init.el that loads them.
298 ;;;See also "site-load" above.
299 (load "site-init" t)
300 (setq current-load-list nil)
302 ;; Write the value of load-history into fns-VERSION.el,
303 ;; then clear out load-history.
304 ;; (if (or (equal (nth 3 command-line-args) "dump")
305 ;; (equal (nth 4 command-line-args) "dump"))
306 ;; (let ((buffer-undo-list t))
307 ;; (princ "(setq load-history\n" (current-buffer))
308 ;; (princ " (nconc load-history\n" (current-buffer))
309 ;; (princ " '(" (current-buffer))
310 ;; (let ((tem load-history))
311 ;; (while tem
312 ;; (prin1 (car tem) (current-buffer))
313 ;; (terpri (current-buffer))
314 ;; (if (cdr tem)
315 ;; (princ " " (current-buffer)))
316 ;; (setq tem (cdr tem))))
317 ;; (princ ")))\n" (current-buffer))
318 ;; (write-region (point-min) (point-max)
319 ;; (expand-file-name
320 ;; (cond
321 ;; ((eq system-type 'ms-dos)
322 ;; "../lib-src/fns.el")
323 ;; ((eq system-type 'windows-nt)
324 ;; (format "../../../lib-src/fns-%s.el" emacs-version))
325 ;; (t
326 ;; (format "../lib-src/fns-%s.el" emacs-version)))
327 ;; invocation-directory))
328 ;; (erase-buffer)
329 ;; (setq load-history nil))
330 ;; (setq symbol-file-load-history-loaded t))
331 ;; We don't use this fns-*.el file. Instead we keep the data in PURE space.
332 ;; Make sure that the spine of the list is not in pure space because it can
333 ;; be destructively mutated in lread.c:build_load_history.
334 (setq load-history (mapcar 'purecopy load-history))
335 (setq symbol-file-load-history-loaded t)
337 (set-buffer-modified-p nil)
339 ;; reset the load-path. See lread.c:init_lread why.
340 (if (or (equal (nth 3 command-line-args) "bootstrap")
341 (equal (nth 4 command-line-args) "bootstrap"))
342 (setcdr load-path nil))
344 (remove-hook 'after-load-functions '(lambda (f) (garbage-collect)))
346 (setq inhibit-load-charset-map nil)
347 (clear-charset-maps)
348 (garbage-collect)
350 ;; At this point, we're ready to resume undo recording for scratch.
351 (buffer-enable-undo "*scratch*")
353 ;; Avoid error if user loads some more libraries now and make sure the
354 ;; hash-consing hash table is GC'd.
355 (setq purify-flag nil)
357 (if (null (garbage-collect))
358 (setq pure-space-overflow t))
360 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
361 (member (nth 4 command-line-args) '("dump" "bootstrap")))
362 (progn
363 (if (memq system-type '(ms-dos windows-nt cygwin))
364 (message "Dumping under the name emacs")
365 (message "Dumping under the name emacs"))
366 (condition-case ()
367 (delete-file "emacs")
368 (file-error nil))
369 ;; We used to dump under the name xemacs, but that occasionally
370 ;; confused people installing Emacs (they'd install the file
371 ;; under the name `xemacs'), and it's inconsistent with every
372 ;; other GNU program's build process.
373 (dump-emacs "emacs" "temacs")
374 (message "%d pure bytes used" pure-bytes-used)
375 ;; Recompute NAME now, so that it isn't set when we dump.
376 (if (not (or (memq system-type '(ms-dos windows-nt cygwin))
377 ;; Don't bother adding another name if we're just
378 ;; building bootstrap-emacs.
379 (equal (nth 3 command-line-args) "bootstrap")
380 (equal (nth 4 command-line-args) "bootstrap")))
381 (let ((name (concat "emacs-" emacs-version)))
382 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
383 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
385 (substring name (match-end 0)))))
386 (message "Adding name %s" name)
387 (add-name-to-file "emacs" name t)))
388 (kill-emacs)))
390 ;; For machines with CANNOT_DUMP defined in config.h,
391 ;; this file must be loaded each time Emacs is run.
392 ;; So run the startup code now. First, remove `-l loadup' from args.
394 (if (and (equal (nth 1 command-line-args) "-l")
395 (equal (nth 2 command-line-args) "loadup"))
396 (setcdr command-line-args (nthcdr 3 command-line-args)))
398 (eval top-level)
401 ;; Local Variables:
402 ;; no-byte-compile: t
403 ;; no-update-autoloads: t
404 ;; End:
406 ;; arch-tag: 121e1dd4-36e1-45ac-860e-239f577a6335
407 ;;; loadup.el ends here