Mercurial > hg > xemacs-beta
annotate lisp/loadup.el @ 4548:b0d2ace4aed1
Call XFreeFontPath appropriately in #'x-get-font-path.
src/ChangeLog addition:
2008-12-30 Aidan Kehoe <kehoea@parhasard.net>
* device-x.c (Fx_get_font_path):
Free the font path once we're finished with it.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 30 Dec 2008 20:01:14 +0000 |
parents | 061e030e3270 |
children | 3465c3161fea |
rev | line source |
---|---|
428 | 1 ;; loadup.el --- load up standardly loaded Lisp files for XEmacs. |
2 | |
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1997 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1996 Richard Mlynarik. | |
1261 | 5 ;; Copyright (C) 1995, 1996, 2003 Ben Wing. |
428 | 6 |
7 ;; Maintainer: XEmacs Development Team | |
8 ;; Keywords: internal, dumped | |
9 | |
10 ;; This file is part of XEmacs. | |
11 | |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | |
13 ;; under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
25 ;; 02111-1307, USA. | |
26 | |
27 ;;; Synched up with: Last synched with FSF 19.30, with wild divergence since. | |
28 | |
29 ;;; Commentary: | |
30 | |
1261 | 31 ;; If you are wanting to add files to be dumped into your local version of |
32 ;; XEmacs, DO NOT add them here. Use site-init.el or site-load.el instead. | |
428 | 33 |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
34 ;; ***Note the docstrings for the variables in this file. They follow the |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
35 ;; conventions described in lib-src/make-docfile.c, and any new variables or |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
36 ;; functions added to this file should follow those conventions too, since |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
37 ;; this file is always loaded uncompiled, and the byte-compiler never gets a |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
38 ;; chance to format the docstrings in the way make-docfile.c understands. |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
39 |
428 | 40 ;; This is loaded into a bare XEmacs to make a dumpable one. |
41 | |
42 ;;; Code: | |
43 | |
1261 | 44 ;; Help debug problems. |
45 (setq stack-trace-on-error t | |
46 load-always-display-messages t) | |
47 | |
1330 | 48 ;(princ (format "command-line-args: %s\n" command-line-args)) |
49 ;(princ (format "configure-lisp-directory: %S\n" configure-lisp-directory)) | |
50 ;(princ (format "configure-data-directory: %S\n" configure-data-directory)) | |
51 ;(princ (format "lisp-directory: %S\n" lisp-directory)) | |
52 | |
428 | 53 (when (fboundp 'error) |
54 (error "loadup.el already loaded!")) | |
55 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
56 (defconst running-xemacs t "\ |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
57 Non-nil when the current emacs is XEmacs.") |
3511 | 58 |
59 ;; Can't make this constant for now because it causes an error in | |
60 ;; update-elc.el. | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
61 (defvar source-lisp (file-name-directory (expand-file-name (nth 2 command-line-args))) "\ |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
62 Root of tree containing the Lisp source code for the current build. |
3511 | 63 Differs from `lisp-directory' if this XEmacs has been installed. ") |
64 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
65 (defconst build-directory (expand-file-name ".." invocation-directory) "\ |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
66 Root of tree containing object files and executables produced by build. |
3511 | 67 Differs from `source-directory' if configured with --srcdir option, a practice |
68 recommended for developers.") | |
69 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
70 (defconst source-directory (expand-file-name ".." source-lisp) "\ |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
71 Root of tree containing source code for the current build. |
3511 | 72 Used during loadup and for documenting source of symbols defined in C.") |
73 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
74 (defvar preloaded-file-list nil "\ |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
75 List of Lisp files preloaded into the XEmacs binary image, |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
76 with the exception of `loadup.el'.") |
428 | 77 |
442 | 78 ;(start-profiling) |
79 | |
80 (let ((gc-cons-threshold | |
81 ;; setting it low makes loadup incredibly fucking slow. | |
82 ;; no need to do it when not dumping. | |
83 (if (and purify-flag | |
84 (not (memq 'quick-build internal-error-checking))) | |
85 30000 3000000))) | |
1261 | 86 |
87 ;; really-early-error-handler outputs a stack trace so let's not do it | |
88 ;; twice. | |
89 (let ((stack-trace-on-error nil)) | |
428 | 90 |
91 ;; This is awfully damn early to be getting an error, right? | |
92 (call-with-condition-handler 'really-early-error-handler | |
93 #'(lambda () | |
1330 | 94 (setq load-path (list source-lisp)) |
3511 | 95 (setq module-load-path (list |
96 (expand-file-name "modules" build-directory))) | |
428 | 97 |
98 ;; message not defined yet ... | |
99 (external-debugging-output (format "\nUsing load-path %s" load-path)) | |
100 (external-debugging-output (format "\nUsing module-load-path %s" | |
101 module-load-path)) | |
102 | |
103 ;; We don't want to have any undo records in the dumped XEmacs. | |
104 (buffer-disable-undo (get-buffer "*scratch*")) | |
105 | |
106 ;; lread.c (or src/Makefile.in.in) has prepended | |
107 ;; "${srcdir}/../lisp/" to load-path, which is how this file | |
108 ;; has been found. At this point, enough of XEmacs has been | |
109 ;; initialized that we can start dumping "standard" lisp. | |
110 ;; Dumped lisp from external packages is added when we search | |
111 ;; the package path. | |
112 ;; #### This code is duplicated in two other places. | |
113 (let ((temp-path (expand-file-name "." (car load-path)))) | |
114 (setq load-path (nconc (mapcar | |
115 #'(lambda (i) (concat i "/")) | |
116 (directory-files temp-path t "^[^-.]" | |
117 nil 'dirs-only)) | |
118 (cons (file-name-as-directory temp-path) | |
119 load-path)))) | |
120 | |
1261 | 121 (setq load-warn-when-source-only t) ; Set to nil at the end |
428 | 122 |
123 ;; garbage collect after loading every file in an attempt to | |
124 ;; minimize the size of the dumped image (if we don't do this, | |
125 ;; there will be lots of extra space in the data segment filled | |
126 ;; with garbage-collected junk) | |
127 (defun pureload (file) | |
128 (let ((full-path | |
129 (locate-file file load-path | |
130 (if load-ignore-elc-files | |
131 '(".el" "") '(".elc" ".el" ""))))) | |
132 (if full-path | |
133 (prog1 | |
134 (load full-path) | |
442 | 135 ;; but garbage collection really slows down loading. |
136 (unless (memq 'quick-build internal-error-checking) | |
137 (garbage-collect))) | |
428 | 138 (external-debugging-output (format "\nLoad file %s: not found\n" |
139 file)) | |
140 ;; Uncomment in case of trouble | |
2456 | 141 ;;(print (format "late-package-hierarchies: %S" late-package-hierarchies)) |
1227 | 142 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p))) |
143 ;;(print (format "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p))) | |
428 | 144 nil))) |
145 | |
1330 | 146 (load (expand-file-name "dumped-lisp.el" source-lisp)) |
428 | 147 |
148 (let ((files preloaded-file-list) | |
149 file) | |
150 (while (setq file (car files)) | |
151 (unless (pureload file) | |
152 (external-debugging-output "Fatal error during load, aborting") | |
153 (kill-emacs 1)) | |
154 (setq files (cdr files))) | |
155 (when (not (featurep 'toolbar)) | |
156 ;; else still define a few functions. | |
157 (defun toolbar-button-p (obj) "No toolbar support." nil) | |
158 (defun toolbar-specifier-p (obj) "No toolbar support." nil)) | |
159 (fmakunbound 'pureload)) | |
160 | |
161 (packages-load-package-dumped-lisps late-package-load-path) | |
162 | |
163 )) ;; end of call-with-condition-handler | |
1261 | 164 |
165 ) ; (let ((stack-trace-on-error nil))) | |
428 | 166 |
167 ;; Fix up the preloaded file list | |
168 (setq preloaded-file-list (mapcar #'file-name-sans-extension | |
169 preloaded-file-list)) | |
170 | |
1261 | 171 (setq load-warn-when-source-only nil) |
428 | 172 |
173 (setq debugger 'debug) | |
174 | |
175 (when (member "no-site-file" command-line-args) | |
176 (setq site-start-file nil)) | |
177 | |
178 ;; If you want additional libraries to be preloaded and their | |
179 ;; doc strings kept in the DOC file rather than in core, | |
180 ;; you may load them with a "site-load.el" file. | |
181 ;; But you must also cause them to be scanned when the DOC file | |
1261 | 182 ;; is generated. For MS Windows, you must edit ../nt/xemacs.mak. |
183 ;; For other systems, you must edit ../src/Makefile.in.in. | |
428 | 184 (when (load "site-load" t) |
442 | 185 (garbage-collect) |
186 ) | |
428 | 187 |
188 ;;FSFmacs randomness | |
189 ;;(if (fboundp 'x-popup-menu) | |
190 ;; (precompute-menubar-bindings)) | |
191 ;;; Turn on recording of which commands get rebound, | |
192 ;;; for the sake of the next call to precompute-menubar-bindings. | |
193 ;(setq define-key-rebound-commands nil) | |
194 | |
195 ;; Note: all compiled Lisp files loaded above this point | |
196 ;; must be among the ones parsed by make-docfile | |
197 ;; to construct DOC. Any that are not processed | |
198 ;; for DOC will not have doc strings in the dumped XEmacs. | |
199 | |
200 ;; Don't bother with these if we're running temacs, i.e. if we're | |
201 ;; just debugging don't waste time finding doc strings. | |
202 | |
203 ;; purify-flag is nil if called from loadup-el.el. | |
204 (when purify-flag | |
205 (message "Finding pointers to doc strings...") | |
206 (Snarf-documentation "DOC") | |
207 (message "Finding pointers to doc strings...done") | |
208 (Verify-documentation)) | |
209 | |
210 ;; Note: You can cause additional libraries to be preloaded | |
211 ;; by writing a site-init.el that loads them. | |
212 ;; See also "site-load" above. | |
213 (when (stringp site-start-file) | |
214 (load "site-init" t)) | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
215 ;; Add information from this file to the load history: |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
216 (setq load-history (cons (nreverse current-load-list) load-history) |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
217 ;; Clear current-load-list; this (and adding information to |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
218 ;; load-history) is normally done in lread.c after reading the |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
219 ;; entirety of a file, something which never happens for loadup.el. |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
220 current-load-list nil) |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
221 ;; Make the path to this file look a little nicer: |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
222 (setcar (car load-history) (file-truename (caar load-history))) |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
223 |
428 | 224 (garbage-collect) |
225 | |
226 ;;; At this point, we're ready to resume undo recording for scratch. | |
227 (buffer-enable-undo "*scratch*") | |
228 | |
1261 | 229 ) ;; (let ((gc-cons-threshold [frequent garbage collection when dumping]))) |
428 | 230 |
442 | 231 ;(stop-profiling) |
232 | |
428 | 233 ;; Dump into the name `xemacs' (only) |
234 (when (member "dump" command-line-args) | |
235 (message "Dumping under the name xemacs") | |
236 ;; This is handled earlier in the build process. | |
237 ;; (condition-case () (delete-file "xemacs") (file-error nil)) | |
238 (when (fboundp 'really-free) | |
239 (really-free)) | |
1261 | 240 ;; Make sure we don't dump with debugging messages turned on. |
241 (setq stack-trace-on-error nil | |
242 load-always-display-messages nil) | |
462 | 243 (dump-emacs |
244 (cond | |
245 ((featurep 'infodock) "infodock") | |
246 ;; #### BILL!!! | |
247 ;; If we want to dump under a name other than `xemacs', do that here! | |
248 ;; ((featurep 'gtk) "xemacs-gtk") | |
249 (t "xemacs")) | |
250 "temacs") | |
428 | 251 (kill-emacs)) |
252 | |
253 ;; Avoid error if user loads some more libraries now. | |
254 (setq purify-flag nil) | |
255 | |
256 (when (member "run-temacs" command-line-args) | |
257 (message "\nBootstrapping from temacs...") | |
258 ;; Remove all args up to and including "run-temacs" | |
259 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args))) | |
260 ;; run-emacs-from-temacs doesn't actually return anyway. | |
261 (kill-emacs)) | |
262 | |
263 ;; XEmacs change | |
264 ;; If you are using 'recompile', then you should have used -l loadup-el.el | |
265 ;; so that the .el files always get loaded (the .elc files may be out-of- | |
266 ;; date or bad). | |
267 (when (member "recompile" command-line-args) | |
268 (setq command-line-args-left (cdr (member "recompile" command-line-args))) | |
269 (batch-byte-recompile-directory) | |
270 (kill-emacs)) | |
271 | |
272 ;; For machines with CANNOT_DUMP defined in config.h, | |
273 ;; this file must be loaded each time Emacs is run. | |
274 ;; So run the startup code now. | |
275 | |
276 (when (not (fboundp 'dump-emacs)) | |
277 ;; Avoid loading loadup.el a second time! | |
278 (setq command-line-args (cdr (cdr command-line-args))) | |
279 (eval top-level)) | |
280 | |
281 ;;; loadup.el ends here |