Mercurial > hg > xemacs-beta
annotate lisp/loadup.el @ 5206:39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
src/ChangeLog addition:
2010-04-17 Aidan Kehoe <kehoea@parhasard.net>
* doc.c (Fdocumentation):
If we have a zero length doc string in DOC, as may happen for
undocumented compiled function objects which nonetheless have file
information stored, return nil.
(Fsnarf_documentation):
DOC info existing for compiled functions without docstrings is
perfectly legitimate, now the file is also used to store file names.
* bytecode.c (set_compiled_function_documentation):
Allow this function to set the documentation successfully for
compiled function objects that don't currently have documentation;
most relevant for functions without docstrings which have file
information stored in DOC.
lib-src/ChangeLog addition:
2010-04-17 Aidan Kehoe <kehoea@parhasard.net>
* make-docfile.c (scan_lisp_file):
Even if a function doesn't have a doc string, store its file name
in DOC.
lisp/ChangeLog addition:
2010-04-17 Aidan Kehoe <kehoea@parhasard.net>
* loadup.el (load-history): Be a bit more discriminate in the
entries we remove from load-history, only removing those where the
information is entirely available from DOC.
Fixes problems finding the files that dumped undocumented
variables were loaded from, reported by Didier Verna.
* loadhist.el (symbol-file): Correct a regexp here, I had
forgotten to double a backslash.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 17 Apr 2010 10:40:03 +0100 |
parents | bedf3747a6d7 |
children | 5efbd1253905 |
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. | |
4841
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
5 ;; Copyright (C) 1995, 1996, 2003, 2005 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) | |
4841
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
47 (when (featurep 'debug-xemacs) |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
48 ;; Immediately dump core upon an unhandled error, rather than just quitting |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
49 ;; the program. This can also be achieved by setting an environment variable |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
50 ;; XEMACSDEBUG to contain '(setq debug-on-error t)', e.g. |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
51 ;; export XEMACSDEBUG='(setq debug-on-error t)' |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
52 (setq debug-on-error t)) |
1261 | 53 |
1330 | 54 ;(princ (format "command-line-args: %s\n" command-line-args)) |
55 ;(princ (format "configure-lisp-directory: %S\n" configure-lisp-directory)) | |
56 ;(princ (format "configure-data-directory: %S\n" configure-data-directory)) | |
57 ;(princ (format "lisp-directory: %S\n" lisp-directory)) | |
58 | |
428 | 59 (when (fboundp 'error) |
60 (error "loadup.el already loaded!")) | |
61 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
62 (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
|
63 Non-nil when the current emacs is XEmacs.") |
3511 | 64 |
65 ;; Can't make this constant for now because it causes an error in | |
66 ;; 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
|
67 (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
|
68 Root of tree containing the Lisp source code for the current build. |
3511 | 69 Differs from `lisp-directory' if this XEmacs has been installed. ") |
70 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
71 (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
|
72 Root of tree containing object files and executables produced by build. |
3511 | 73 Differs from `source-directory' if configured with --srcdir option, a practice |
74 recommended for developers.") | |
75 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
76 (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
|
77 Root of tree containing source code for the current build. |
3511 | 78 Used during loadup and for documenting source of symbols defined in C.") |
79 | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
80 (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
|
81 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
|
82 with the exception of `loadup.el'.") |
428 | 83 |
442 | 84 ;(start-profiling) |
85 | |
86 (let ((gc-cons-threshold | |
87 ;; setting it low makes loadup incredibly fucking slow. | |
88 ;; no need to do it when not dumping. | |
89 (if (and purify-flag | |
90 (not (memq 'quick-build internal-error-checking))) | |
91 30000 3000000))) | |
1261 | 92 |
93 ;; really-early-error-handler outputs a stack trace so let's not do it | |
94 ;; twice. | |
95 (let ((stack-trace-on-error nil)) | |
428 | 96 |
97 ;; This is awfully damn early to be getting an error, right? | |
98 (call-with-condition-handler 'really-early-error-handler | |
99 #'(lambda () | |
1330 | 100 (setq load-path (list source-lisp)) |
3511 | 101 (setq module-load-path (list |
102 (expand-file-name "modules" build-directory))) | |
428 | 103 |
104 ;; message not defined yet ... | |
105 (external-debugging-output (format "\nUsing load-path %s" load-path)) | |
106 (external-debugging-output (format "\nUsing module-load-path %s" | |
107 module-load-path)) | |
108 | |
109 ;; We don't want to have any undo records in the dumped XEmacs. | |
110 (buffer-disable-undo (get-buffer "*scratch*")) | |
111 | |
112 ;; lread.c (or src/Makefile.in.in) has prepended | |
113 ;; "${srcdir}/../lisp/" to load-path, which is how this file | |
114 ;; has been found. At this point, enough of XEmacs has been | |
115 ;; initialized that we can start dumping "standard" lisp. | |
116 ;; Dumped lisp from external packages is added when we search | |
117 ;; the package path. | |
118 ;; #### This code is duplicated in two other places. | |
119 (let ((temp-path (expand-file-name "." (car load-path)))) | |
120 (setq load-path (nconc (mapcar | |
121 #'(lambda (i) (concat i "/")) | |
122 (directory-files temp-path t "^[^-.]" | |
123 nil 'dirs-only)) | |
124 (cons (file-name-as-directory temp-path) | |
125 load-path)))) | |
126 | |
1261 | 127 (setq load-warn-when-source-only t) ; Set to nil at the end |
428 | 128 |
129 ;; garbage collect after loading every file in an attempt to | |
130 ;; minimize the size of the dumped image (if we don't do this, | |
131 ;; there will be lots of extra space in the data segment filled | |
132 ;; with garbage-collected junk) | |
133 (defun pureload (file) | |
134 (let ((full-path | |
135 (locate-file file load-path | |
136 (if load-ignore-elc-files | |
137 '(".el" "") '(".elc" ".el" ""))))) | |
138 (if full-path | |
139 (prog1 | |
140 (load full-path) | |
442 | 141 ;; but garbage collection really slows down loading. |
142 (unless (memq 'quick-build internal-error-checking) | |
143 (garbage-collect))) | |
428 | 144 (external-debugging-output (format "\nLoad file %s: not found\n" |
145 file)) | |
146 ;; Uncomment in case of trouble | |
2456 | 147 ;;(print (format "late-package-hierarchies: %S" late-package-hierarchies)) |
1227 | 148 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p))) |
149 ;;(print (format "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p))) | |
428 | 150 nil))) |
151 | |
1330 | 152 (load (expand-file-name "dumped-lisp.el" source-lisp)) |
428 | 153 |
154 (let ((files preloaded-file-list) | |
155 file) | |
156 (while (setq file (car files)) | |
157 (unless (pureload file) | |
158 (external-debugging-output "Fatal error during load, aborting") | |
159 (kill-emacs 1)) | |
160 (setq files (cdr files))) | |
161 (when (not (featurep 'toolbar)) | |
162 ;; else still define a few functions. | |
163 (defun toolbar-button-p (obj) "No toolbar support." nil) | |
164 (defun toolbar-specifier-p (obj) "No toolbar support." nil)) | |
165 (fmakunbound 'pureload)) | |
166 | |
167 (packages-load-package-dumped-lisps late-package-load-path) | |
168 | |
169 )) ;; end of call-with-condition-handler | |
1261 | 170 |
171 ) ; (let ((stack-trace-on-error nil))) | |
428 | 172 |
173 ;; Fix up the preloaded file list | |
174 (setq preloaded-file-list (mapcar #'file-name-sans-extension | |
175 preloaded-file-list)) | |
176 | |
1261 | 177 (setq load-warn-when-source-only nil) |
428 | 178 |
179 (setq debugger 'debug) | |
180 | |
181 (when (member "no-site-file" command-line-args) | |
182 (setq site-start-file nil)) | |
183 | |
184 ;; If you want additional libraries to be preloaded and their | |
185 ;; doc strings kept in the DOC file rather than in core, | |
186 ;; you may load them with a "site-load.el" file. | |
187 ;; But you must also cause them to be scanned when the DOC file | |
1261 | 188 ;; is generated. For MS Windows, you must edit ../nt/xemacs.mak. |
189 ;; For other systems, you must edit ../src/Makefile.in.in. | |
428 | 190 (when (load "site-load" t) |
442 | 191 (garbage-collect) |
192 ) | |
428 | 193 |
194 ;;FSFmacs randomness | |
195 ;;(if (fboundp 'x-popup-menu) | |
196 ;; (precompute-menubar-bindings)) | |
197 ;;; Turn on recording of which commands get rebound, | |
198 ;;; for the sake of the next call to precompute-menubar-bindings. | |
199 ;(setq define-key-rebound-commands nil) | |
200 | |
201 ;; Note: all compiled Lisp files loaded above this point | |
202 ;; must be among the ones parsed by make-docfile | |
203 ;; to construct DOC. Any that are not processed | |
204 ;; for DOC will not have doc strings in the dumped XEmacs. | |
205 | |
206 ;; Don't bother with these if we're running temacs, i.e. if we're | |
207 ;; just debugging don't waste time finding doc strings. | |
208 | |
209 ;; purify-flag is nil if called from loadup-el.el. | |
210 (when purify-flag | |
211 (message "Finding pointers to doc strings...") | |
212 (Snarf-documentation "DOC") | |
213 (message "Finding pointers to doc strings...done") | |
214 (Verify-documentation)) | |
215 | |
216 ;; Note: You can cause additional libraries to be preloaded | |
217 ;; by writing a site-init.el that loads them. | |
218 ;; See also "site-load" above. | |
219 (when (stringp site-start-file) | |
220 (load "site-init" t)) | |
4915
bedf3747a6d7
Use DOC for dumped Lisp file names; Xref to source-lisp if readable, symbol-file
Aidan Kehoe <kehoea@parhasard.net>
parents:
4899
diff
changeset
|
221 |
bedf3747a6d7
Use DOC for dumped Lisp file names; Xref to source-lisp if readable, symbol-file
Aidan Kehoe <kehoea@parhasard.net>
parents:
4899
diff
changeset
|
222 ;; Add information from this file to the load history. Delete information |
5206
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
223 ;; that is available from DOC for those files in preloaded-file-list; in |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
224 ;; practice, this boils down to #'provide and #'require calls, and variables |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
225 ;; without documentation. Yes, this is a bit ugly. |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
226 (setq load-history (cons (nreverse current-load-list) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
227 (delete* |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
228 nil |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
229 (mapc #'(lambda (element) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
230 (remassq 'defun element) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
231 (delete-if |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
232 #'(lambda (elt) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
233 (and |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
234 (symbolp elt) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
235 (get elt 'variable-documentation))) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
236 element)) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
237 load-history) |
39d74978fd32
Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4915
diff
changeset
|
238 :key #'cdr)) |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
239 ;; 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
|
240 ;; 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
|
241 ;; 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
|
242 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
|
243 ;; 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
|
244 (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
|
245 |
428 | 246 (garbage-collect) |
247 | |
248 ;;; At this point, we're ready to resume undo recording for scratch. | |
249 (buffer-enable-undo "*scratch*") | |
250 | |
1261 | 251 ) ;; (let ((gc-cons-threshold [frequent garbage collection when dumping]))) |
428 | 252 |
442 | 253 ;(stop-profiling) |
254 | |
428 | 255 ;; Dump into the name `xemacs' (only) |
256 (when (member "dump" command-line-args) | |
257 (message "Dumping under the name xemacs") | |
258 ;; This is handled earlier in the build process. | |
259 ;; (condition-case () (delete-file "xemacs") (file-error nil)) | |
260 (when (fboundp 'really-free) | |
261 (really-free)) | |
1261 | 262 ;; Make sure we don't dump with debugging messages turned on. |
263 (setq stack-trace-on-error nil | |
4841
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
264 load-always-display-messages nil |
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4539
diff
changeset
|
265 debug-on-error nil) |
462 | 266 (dump-emacs |
267 (cond | |
268 ((featurep 'infodock) "infodock") | |
269 ;; #### BILL!!! | |
270 ;; If we want to dump under a name other than `xemacs', do that here! | |
271 ;; ((featurep 'gtk) "xemacs-gtk") | |
272 (t "xemacs")) | |
273 "temacs") | |
428 | 274 (kill-emacs)) |
275 | |
276 ;; Avoid error if user loads some more libraries now. | |
277 (setq purify-flag nil) | |
278 | |
279 (when (member "run-temacs" command-line-args) | |
280 (message "\nBootstrapping from temacs...") | |
281 ;; Remove all args up to and including "run-temacs" | |
282 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args))) | |
283 ;; run-emacs-from-temacs doesn't actually return anyway. | |
284 (kill-emacs)) | |
285 | |
286 ;; XEmacs change | |
287 ;; If you are using 'recompile', then you should have used -l loadup-el.el | |
288 ;; so that the .el files always get loaded (the .elc files may be out-of- | |
289 ;; date or bad). | |
290 (when (member "recompile" command-line-args) | |
291 (setq command-line-args-left (cdr (member "recompile" command-line-args))) | |
292 (batch-byte-recompile-directory) | |
293 (kill-emacs)) | |
294 | |
295 ;; For machines with CANNOT_DUMP defined in config.h, | |
296 ;; this file must be loaded each time Emacs is run. | |
297 ;; So run the startup code now. | |
298 | |
299 (when (not (fboundp 'dump-emacs)) | |
300 ;; Avoid loading loadup.el a second time! | |
301 (setq command-line-args (cdr (cdr command-line-args))) | |
302 (eval top-level)) | |
303 | |
304 ;;; loadup.el ends here |