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