Major rewrite to behave more like a minor mode.
[bpt/emacs.git] / lisp / loadup.el
1 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs.
2
3 ;; Copyright (C) 1985, 1986, 1992, 1994 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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;; This is loaded into a bare Emacs to make a dumpable one.
27
28 ;;; Code:
29
30 (message "Using load-path %s" load-path)
31
32 ;;; We don't want to have any undo records in the dumped Emacs.
33 (buffer-disable-undo "*scratch*")
34
35 (load "subr")
36 (garbage-collect)
37 (load "byte-run")
38 (garbage-collect)
39 (load "map-ynp")
40 (garbage-collect)
41 (load "loaddefs.el") ;Don't get confused if someone compiled loaddefs by mistake.
42 (garbage-collect)
43 (load "simple")
44 (garbage-collect)
45 (load "help")
46 (garbage-collect)
47 (load "files")
48 (garbage-collect)
49 (load "indent")
50 (garbage-collect)
51 (load "window")
52 (garbage-collect)
53 (if (fboundp 'delete-frame)
54 (progn
55 (load "frame")
56 (load "mouse")
57 (garbage-collect)
58 (load "faces")
59 (garbage-collect)
60 (load "menu-bar")
61 (load "scroll-bar")
62 (load "select")))
63 (garbage-collect)
64 (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
65 (garbage-collect)
66 (load "startup")
67 (garbage-collect)
68 (load "lisp")
69 (garbage-collect)
70 (load "page")
71 (garbage-collect)
72 (load "register")
73 (garbage-collect)
74 (load "paragraphs")
75 (garbage-collect)
76 (load "lisp-mode")
77 (garbage-collect)
78 (load "text-mode")
79 (garbage-collect)
80 (load "fill")
81 (garbage-collect)
82 (load "c-mode")
83 (garbage-collect)
84 (load "isearch")
85 (garbage-collect)
86 (load "replace")
87 (if (eq system-type 'vax-vms)
88 (progn
89 (garbage-collect)
90 (load "vmsproc")))
91 (garbage-collect)
92 (load "abbrev")
93 (garbage-collect)
94 (load "buff-menu")
95 (if (eq system-type 'vax-vms)
96 (progn
97 (garbage-collect)
98 (load "vms-patch")))
99 (if (eq system-type 'ms-dos)
100 (progn
101 (load "ls-lisp")
102 (garbage-collect)
103 (load "mouse")
104 (garbage-collect)
105 (load "dos-fns")
106 (garbage-collect)
107 (load "disp-table") ; needed to setup ibm-pc char set, see internal.el
108 (garbage-collect)))
109 (if (fboundp 'atan) ; preload some constants and
110 (progn ; floating pt. functions if
111 (garbage-collect) ; we have float support.
112 (load "float-sup")))
113 (garbage-collect)
114 (load "vc-hooks")
115
116 ;; We specify .el in case someone compiled version.el by mistake.
117 (load "version.el")
118
119 ;If you want additional libraries to be preloaded and their
120 ;doc strings kept in the DOC file rather than in core,
121 ;you may load them with a "site-load.el" file.
122 ;But you must also cause them to be scanned when the DOC file
123 ;is generated. For VMS, you must edit ../vms/makedoc.com.
124 ;For other systems, you must edit ../src/Makefile.in.in.
125 (if (load "site-load" t)
126 (garbage-collect))
127
128 ;; Determine which last version number to use
129 ;; based on the executables that now exist.
130 (if (and (or (equal (nth 3 command-line-args) "dump")
131 (equal (nth 4 command-line-args) "dump"))
132 (not (eq system-type 'ms-dos)))
133 (let* ((base (concat "emacs-" emacs-version))
134 (files (file-name-all-completions base default-directory))
135 (versions (mapcar (function (lambda (name)
136 (string-to-int (substring name (1+ (length base))))))
137 files)))
138 (setq emacs-version (format "%s.%d"
139 emacs-version
140 (if versions
141 (1+ (apply 'max versions))
142 1)))))
143
144 ;; Note: all compiled Lisp files loaded above this point
145 ;; must be among the ones parsed by make-docfile
146 ;; to construct DOC. Any that are not processed
147 ;; for DOC will not have doc strings in the dumped Emacs.
148
149 (message "Finding pointers to doc strings...")
150 (if (or (equal (nth 3 command-line-args) "dump")
151 (equal (nth 4 command-line-args) "dump"))
152 (let ((name emacs-version))
153 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
154 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
155 "-"
156 (substring name (match-end 0)))))
157 (if (eq system-type 'ms-dos)
158 (setq name (expand-file-name "../etc/DOC"))
159 (setq name (concat (expand-file-name "../etc/DOC-") name))
160 (if (file-exists-p name)
161 (delete-file name))
162 (copy-file (expand-file-name "../etc/DOC") name t))
163 (Snarf-documentation (file-name-nondirectory name)))
164 (Snarf-documentation "DOC"))
165 (message "Finding pointers to doc strings...done")
166
167 ;Note: You can cause additional libraries to be preloaded
168 ;by writing a site-init.el that loads them.
169 ;See also "site-load" above.
170 (load "site-init" t)
171 (setq current-load-list nil)
172 (garbage-collect)
173
174 ;;; At this point, we're ready to resume undo recording for scratch.
175 (buffer-enable-undo "*scratch*")
176
177 (if (or (equal (nth 3 command-line-args) "dump")
178 (equal (nth 4 command-line-args) "dump"))
179 (if (eq system-type 'vax-vms)
180 (progn
181 (message "Dumping data as file temacs.dump")
182 (dump-emacs "temacs.dump" "temacs")
183 (kill-emacs))
184 (let ((name (concat "emacs-" emacs-version)))
185 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
186 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
187 "-"
188 (substring name (match-end 0)))))
189 (if (eq system-type 'ms-dos)
190 (message "Dumping under the name emacs")
191 (message "Dumping under names emacs and %s" name)))
192 (condition-case ()
193 (delete-file "emacs")
194 (file-error nil))
195 ;; We used to dump under the name xemacs, but that occasionally
196 ;; confused people installing Emacs (they'd install the file
197 ;; under the name `xemacs'), and it's inconsistent with every
198 ;; other GNU product's build process.
199 (dump-emacs "emacs" "temacs")
200 ;; Recompute NAME now, so that it isn't set when we dump.
201 (if (not (eq system-type 'ms-dos))
202 (let ((name (concat "emacs-" emacs-version)))
203 (while (string-match "[^-+_.a-zA-Z0-9]+" name)
204 (setq name (concat (downcase (substring name 0 (match-beginning 0)))
205 "-"
206 (substring name (match-end 0)))))
207 (add-name-to-file "emacs" name t)))
208 (kill-emacs)))
209
210 ;; Avoid error if user loads some more libraries now.
211 (setq purify-flag nil)
212
213 ;; For machines with CANNOT_DUMP defined in config.h,
214 ;; this file must be loaded each time Emacs is run.
215 ;; So run the startup code now.
216
217 (or (or (equal (nth 3 command-line-args) "dump")
218 (equal (nth 4 command-line-args) "dump"))
219 (eval top-level))
220
221 ;;; loadup.el ends here