Tweaks to Customize interface. Set custom-reset-button-menu to t.
[emacs.git] / lisp / loadup.el
blobf7ffa27a9edbbb42e021f075712207e341ca6507
1 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
3 ;; Copyright (C) 1985-1986, 1992, 1994, 2001-2012
4 ;; 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 any platform should appear in $lisp in src/lisp.mk.
33 ;; Use the .el or .elc version as appropriate.
35 ;; This ensures both that the Lisp files are compiled (if necessary)
36 ;; before the emacs executable is dumped, and that they are passed to
37 ;; make-docfile. (Any that are not processed for DOC will not have
38 ;; doc strings in the dumped Emacs.) Because of this:
40 ;; ii) If the file is loaded uncompiled, it should (where possible)
41 ;; obey the doc-string conventions expected by make-docfile.
43 ;;; Code:
45 ;; Add subdirectories to the load-path for files that might get
46 ;; autoloaded when bootstrapping.
47 (if (or (equal (nth 3 command-line-args) "bootstrap")
48 (equal (nth 4 command-line-args) "bootstrap")
49 (equal (nth 3 command-line-args) "unidata-gen.el")
50 (equal (nth 4 command-line-args) "unidata-gen-files")
51 ;; In case CANNOT_DUMP.
52 (string-match "src/bootstrap-emacs" (nth 0 command-line-args)))
53 (let ((dir (car load-path)))
54 ;; We'll probably overflow the pure space.
55 (setq purify-flag nil)
56 (setq load-path (list dir
57 (expand-file-name "emacs-lisp" dir)
58 (expand-file-name "language" dir)
59 (expand-file-name "international" dir)
60 (expand-file-name "textmodes" dir)))))
62 (if (eq t purify-flag)
63 ;; Hash consing saved around 11% of pure space in my tests.
64 (setq purify-flag (make-hash-table :test 'equal)))
66 (message "Using load-path %s" load-path)
68 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
69 (member (nth 4 command-line-args) '("dump" "bootstrap")))
70 ;; To reduce the size of dumped Emacs, we avoid making huge
71 ;; char-tables.
72 (setq inhibit-load-charset-map t))
74 ;; We don't want to have any undo records in the dumped Emacs.
75 (set-buffer "*scratch*")
76 (setq buffer-undo-list t)
78 (load "emacs-lisp/byte-run")
79 (load "emacs-lisp/backquote")
80 (load "subr")
82 ;; Do it after subr, since both after-load-functions and add-hook are
83 ;; implemented in subr.el.
84 (add-hook 'after-load-functions (lambda (f) (garbage-collect)))
86 ;; We specify .el in case someone compiled version.el by mistake.
87 (load "version.el")
89 (load "widget")
90 (load "custom")
91 (load "emacs-lisp/map-ynp")
92 (load "international/mule")
93 (load "international/mule-conf")
94 (load "env")
95 (load "format")
96 (load "bindings")
97 (load "cus-start")
98 (load "window") ; Needed here for `replace-buffer-in-windows'.
99 (setq load-source-file-function 'load-with-code-conversion)
100 (load "files")
102 (load "cus-face")
103 (load "faces") ; after here, `defface' may be used.
105 (load "button")
106 (load "startup")
108 (condition-case nil
109 ;; Don't get confused if someone compiled this by mistake.
110 (load "loaddefs.el")
111 ;; In case loaddefs hasn't been generated yet.
112 (file-error (load "ldefs-boot.el")))
114 (load "minibuffer")
115 (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
116 (load "simple")
118 (load "help")
120 (load "jka-cmpr-hook")
121 (load "epa-hook")
122 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
123 ;; multilingual text.
124 (load "international/mule-cmds")
125 (load "case-table")
126 ;; This file doesn't exist when building a development version of Emacs
127 ;; from the repository. It is generated just after temacs is built.
128 (load "international/charprop.el" t)
129 (load "international/characters")
130 (load "composite")
132 ;; Load language-specific files.
133 (load "language/chinese")
134 (load "language/cyrillic")
135 (load "language/indian")
136 (load "language/sinhala")
137 (load "language/english")
138 (load "language/ethiopic")
139 (load "language/european")
140 (load "language/czech")
141 (load "language/slovak")
142 (load "language/romanian")
143 (load "language/greek")
144 (load "language/hebrew")
145 (load "language/japanese")
146 (load "language/korean")
147 (load "language/lao")
148 (load "language/tai-viet")
149 (load "language/thai")
150 (load "language/tibetan")
151 (load "language/vietnamese")
152 (load "language/misc-lang")
153 (load "language/utf-8-lang")
154 (load "language/georgian")
155 (load "language/khmer")
156 (load "language/burmese")
157 (load "language/cham")
159 (load "indent")
160 (load "frame")
161 (load "term/tty-colors")
162 (load "font-core")
163 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
164 ;; needs to be defined when font-lock is loaded.
165 (load "facemenu")
166 (load "emacs-lisp/syntax")
167 (load "font-lock")
168 (load "jit-lock")
170 (if (fboundp 'track-mouse)
171 (progn
172 (load "mouse")
173 (and (boundp 'x-toolkit-scroll-bars)
174 (load "scroll-bar"))
175 (load "select")))
176 (load "emacs-lisp/timer")
177 (load "isearch")
178 (load "rfn-eshadow")
180 (load "menu-bar")
181 (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
182 (load "emacs-lisp/lisp")
183 (load "textmodes/page")
184 (load "register")
185 (load "textmodes/paragraphs")
186 (load "emacs-lisp/lisp-mode")
187 (load "textmodes/text-mode")
188 (load "textmodes/fill")
190 (load "replace")
191 (load "buff-menu")
193 (if (fboundp 'x-create-frame)
194 (progn
195 (load "fringe")
196 ;; Needed by `imagemagick-register-types'
197 (load "emacs-lisp/regexp-opt")
198 (load "image")
199 (load "international/fontset")
200 (load "dnd")
201 (load "tool-bar")))
203 (if (featurep 'dynamic-setting)
204 (load "dynamic-setting"))
206 (if (featurep 'x)
207 (progn
208 (load "x-dnd")
209 (load "term/common-win")
210 (load "term/x-win")))
212 (if (eq system-type 'windows-nt)
213 (progn
214 (load "w32-vars")
215 (load "term/common-win")
216 (load "term/w32-win")
217 (load "ls-lisp")
218 (load "disp-table")
219 (load "dos-w32")
220 (load "w32-fns")))
221 (if (eq system-type 'ms-dos)
222 (progn
223 (load "dos-w32")
224 (load "dos-fns")
225 (load "dos-vars")
226 ;; Don't load term/common-win: it isn't appropriate for the `pc'
227 ;; ``window system'', which generally behaves like a terminal.
228 (load "term/pc-win")
229 (load "ls-lisp")
230 (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
231 (if (featurep 'ns)
232 (progn
233 (load "term/common-win")
234 (load "term/ns-win")))
235 (if (fboundp 'x-create-frame)
236 ;; Do it after loading term/foo-win.el since the value of the
237 ;; mouse-wheel-*-event vars depends on those files being loaded or not.
238 (load "mwheel"))
239 ;; Preload some constants and floating point functions.
240 (load "emacs-lisp/float-sup")
242 (load "vc/vc-hooks")
243 (load "vc/ediff-hook")
244 (if (fboundp 'x-show-tip) (load "tooltip"))
246 ;If you want additional libraries to be preloaded and their
247 ;doc strings kept in the DOC file rather than in core,
248 ;you may load them with a "site-load.el" file.
249 ;But you must also cause them to be scanned when the DOC file
250 ;is generated.
251 ;For other systems, you must edit ../src/Makefile.in.
252 (load "site-load" t)
254 ;; Determine which last version number to use
255 ;; based on the executables that now exist.
256 (if (and (or (equal (nth 3 command-line-args) "dump")
257 (equal (nth 4 command-line-args) "dump"))
258 (not (eq system-type 'ms-dos)))
259 (let* ((base (concat "emacs-" emacs-version "."))
260 (files (file-name-all-completions base default-directory))
261 (versions (mapcar (function (lambda (name)
262 (string-to-number (substring name (length base)))))
263 files)))
264 (setq emacs-bzr-version (condition-case nil (emacs-bzr-get-version)
265 (error nil)))
266 ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
267 (defconst emacs-version
268 (format "%s.%d"
269 emacs-version (if versions (1+ (apply 'max versions)) 1)))))
272 (message "Finding pointers to doc strings...")
273 (if (or (equal (nth 3 command-line-args) "dump")
274 (equal (nth 4 command-line-args) "dump"))
275 (let ((name emacs-version))
276 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
277 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
279 (substring name (match-end 0)))))
280 (if (memq system-type '(ms-dos windows-nt))
281 (setq name (expand-file-name
282 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
283 (setq name (concat (expand-file-name "../etc/DOC-") name))
284 (if (file-exists-p name)
285 (delete-file name))
286 (copy-file (expand-file-name "../etc/DOC") name t))
287 (Snarf-documentation (file-name-nondirectory name)))
288 (condition-case nil
289 (Snarf-documentation "DOC")
290 (error nil)))
291 (message "Finding pointers to doc strings...done")
293 ;; Note: You can cause additional libraries to be preloaded
294 ;; by writing a site-init.el that loads them.
295 ;; See also "site-load" above.
296 (load "site-init" t)
297 (setq current-load-list nil)
299 ;; We keep the load-history data in PURE space.
300 ;; Make sure that the spine of the list is not in pure space because it can
301 ;; be destructively mutated in lread.c:build_load_history.
302 (setq load-history (mapcar 'purecopy load-history))
304 (set-buffer-modified-p nil)
306 ;; reset the load-path. See lread.c:init_lread why.
307 (if (or (equal (nth 3 command-line-args) "bootstrap")
308 (equal (nth 4 command-line-args) "bootstrap"))
309 (setcdr load-path nil))
311 (remove-hook 'after-load-functions (lambda (f) (garbage-collect)))
313 (setq inhibit-load-charset-map nil)
314 (clear-charset-maps)
315 (garbage-collect)
317 ;; At this point, we're ready to resume undo recording for scratch.
318 (buffer-enable-undo "*scratch*")
320 ;; Avoid error if user loads some more libraries now and make sure the
321 ;; hash-consing hash table is GC'd.
322 (setq purify-flag nil)
324 (if (null (garbage-collect))
325 (setq pure-space-overflow t))
327 (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
328 (member (nth 4 command-line-args) '("dump" "bootstrap")))
329 (progn
330 (if (memq system-type '(ms-dos windows-nt cygwin))
331 (message "Dumping under the name emacs")
332 (message "Dumping under the name emacs"))
333 (condition-case ()
334 (delete-file "emacs")
335 (file-error nil))
336 ;; We used to dump under the name xemacs, but that occasionally
337 ;; confused people installing Emacs (they'd install the file
338 ;; under the name `xemacs'), and it's inconsistent with every
339 ;; other GNU program's build process.
340 (dump-emacs "emacs" "temacs")
341 (message "%d pure bytes used" pure-bytes-used)
342 ;; Recompute NAME now, so that it isn't set when we dump.
343 (if (not (or (memq system-type '(ms-dos windows-nt))
344 ;; Don't bother adding another name if we're just
345 ;; building bootstrap-emacs.
346 (equal (nth 3 command-line-args) "bootstrap")
347 (equal (nth 4 command-line-args) "bootstrap")))
348 (let ((name (concat "emacs-" emacs-version)))
349 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
350 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
352 (substring name (match-end 0)))))
353 (message "Adding name %s" name)
354 (add-name-to-file "emacs" name t)))
355 (kill-emacs)))
357 ;; For machines with CANNOT_DUMP defined in config.h,
358 ;; this file must be loaded each time Emacs is run.
359 ;; So run the startup code now. First, remove `-l loadup' from args.
361 (if (and (equal (nth 1 command-line-args) "-l")
362 (equal (nth 2 command-line-args) "loadup"))
363 (setcdr command-line-args (nthcdr 3 command-line-args)))
365 (eval top-level)
368 ;; Local Variables:
369 ;; no-byte-compile: t
370 ;; no-update-autoloads: t
371 ;; End:
373 ;;; loadup.el ends here