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