comparison lisp/loadhist.el @ 4539:061e030e3270

Fix some bugs in load-history construction, built-in symbol file names. lib-src/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * make-docfile.c (main): Allow more than one -d argument, followed by a directory to change to. (put_filename): Don't strip directory information; with previous change, allows retrieval of Lisp function and variable origin files from #'built-in-symbol-file relative to lisp-directory. (scan_lisp_file): Don't add an extraneous newline after the file name, put_filename has added the newline already. lisp/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * loadup.el (load-history): Add the contents of current-load-list to load-history before clearing it. Move the variable declarations earlier in the file to a format understood by make-docfile.c. * custom.el (custom-declare-variable): Add the variable's symbol to the current file's load history entry correctly, don't use a cons. Eliminate a comment that we don't need to worry about, we don't need to check the `initialized' C variable in Lisp. * bytecomp.el (byte-compile-output-file-form): Merge Andreas Schwab's pre-GPLv3 GNU change of 19970831 here; treat #'custom-declare-variable correctly, generating the docstrings in a format understood by make-docfile.c. * loadhist.el (symbol-file): Correct behaviour for checking autoloaded macros and functions when supplied with a TYPE argument. Accept fully-qualified paths from #'built-in-symbol-file; if a path is not fully-qualified, return it relative to lisp-directory if the filename corresponds to a Lisp file, and relative to (concat source-directory "/src/") otherwise. * make-docfile.el (preloaded-file-list): Rationalise some let bindings a little. Use the "-d" argument to make-docfile.c to supply Lisp paths relative to lisp-directory, not absolutely. Add in loadup.el explicitly to the list of files to be processed by make-docfile.c--it doesn't make sense to add it to preloaded-file-list, since that is used for purposes of byte-compilation too. src/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * doc.c (Fbuilt_in_symbol_file): Return a subr's filename immediately if we've found it. Check for compiled function and compiled macro docstrings in DOC too, and return them if they exist. The branch of the if statement focused on functions may have executed, but we may still want to check variable bindings; an else clause isn't appropriate.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 27 Dec 2008 14:05:50 +0000
parents 69a1eda3da06
children 7e01763ea656
comparison
equal deleted inserted replaced
4535:69a1eda3da06 4539:061e030e3270
37 ;;; Code: 37 ;;; Code:
38 38
39 ;; load-history is a list of entries that look like this: 39 ;; load-history is a list of entries that look like this:
40 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...) 40 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...)
41 41
42 ;; XEmacs; this function is in subr.el in GNU, and does not deal with
43 ;; built-in symbols.
42 (defun symbol-file (sym &optional type) 44 (defun symbol-file (sym &optional type)
43 "Return the input source from which SYM was loaded. 45 "Return the input source from which SYM was loaded.
44 This is a file name, or nil if the source was a buffer with no associated file. 46 This is a file name, or nil if the source was a buffer with no associated file.
45 47
46 If TYPE is nil or omitted, any kind of definition is acceptable. 48 If TYPE is nil or omitted, any kind of definition is acceptable.
50 52
51 `defface' specifies a face definition only, and for the moment, it won't 53 `defface' specifies a face definition only, and for the moment, it won't
52 return faces created with `make-face' or `copy-face', just those created 54 return faces created with `make-face' or `copy-face', just those created
53 with `defface' and `custom-declare-face'." 55 with `defface' and `custom-declare-face'."
54 (interactive "SFind source file for symbol: ") ; XEmacs 56 (interactive "SFind source file for symbol: ") ; XEmacs
55 (block look-up-symbol-file 57 (let (built-in-file autoload-cons symbol-details)
56 (let (built-in-file autoload-cons symbol-details) 58 (cond ((and (eq 'autoload
57 (when (and 59 (car-safe
58 (eq 'autoload 60 (setq autoload-cons
59 (car-safe (setq autoload-cons 61 (and (fboundp sym) (symbol-function sym)))))
60 (and (fboundp sym) 62 (or (and (or (null type) (eq 'defvar type))
61 (symbol-function sym))))) 63 (eq (fifth autoload-cons) 'keymap))
62 (or (and (or (null type) (eq 'defvar type)) 64 (and (or (null type) (eq 'defun type))
63 (eq (fifth autoload-cons) 'keymap)) 65 (memq (fifth autoload-cons) '(nil macro)))))
64 (and (or (null type) (eq 'defvar type)) 66 (return (locate-library (second autoload-cons))))
65 (memq (fifth autoload-cons) '(nil macro))))) 67 ((eq 'defvar type)
66 (return-from look-up-symbol-file 68 ;; Load history entries corresponding to variables are just
67 (locate-library (second autoload-cons)))) 69 ;; symbols.
68 (cond ((eq 'defvar type) 70 (dolist (entry load-history)
69 ;; Load history entries corresponding to variables are just 71 (when (memq sym (cdr entry))
70 ;; symbols. 72 (return (car entry)))))
71 (dolist (entry load-history) 73 ((not (null type))
72 (when (memq sym (cdr entry)) 74 ;; Non-variables have the type stored as the car of the entry.
73 (return-from look-up-symbol-file (car entry))))) 75 (dolist (entry load-history)
74 ((not (null type)) 76 (when (and (setq symbol-details (rassq sym (cdr entry)))
75 ;; Non-variables have the type stored as the car of the entry. 77 (eq type (car symbol-details)))
76 (dolist (entry load-history) 78 (return (car entry)))))
77 (when (and (setq symbol-details (rassq sym (cdr entry))) 79 (t
78 (eq type (car symbol-details))) 80 ;; If TYPE hasn't been specified, we need to check both for
79 (return-from look-up-symbol-file (car entry))))) 81 ;; variables and other symbols.
80 (t 82 (dolist (entry load-history)
81 ;; If TYPE hasn't been specified, we need to check both for 83 (when (or (memq sym (cdr entry))
82 ;; variables and other symbols. 84 (rassq sym (cdr entry)))
83 (dolist (entry load-history) 85 (return (car entry))))))
84 (when (or (memq sym (cdr entry)) 86 (when (setq built-in-file (built-in-symbol-file sym type))
85 (rassq sym (cdr entry))) 87 (if (equal built-in-file (file-truename built-in-file))
86 (return-from look-up-symbol-file (car entry)))))) 88 ;; Probably a full path name:
87 (setq built-in-file (built-in-symbol-file sym type)) 89 built-in-file
88 (if built-in-file (concat source-directory "/src/" built-in-file))))) 90 ;; This is a bit heuristic, but shouldn't realistically be a
91 ;; problem:
92 (if (string-match "\.elc?$" built-in-file)
93 (concat lisp-directory built-in-file)
94 (concat source-directory "/src/" built-in-file))))))
89 95
90 (defun feature-symbols (feature) 96 (defun feature-symbols (feature)
91 "Return the file and list of symbols associated with a given FEATURE." 97 "Return the file and list of symbols associated with a given FEATURE."
92 (let ((pair `(provide . ,feature))) 98 (let ((pair `(provide . ,feature)))
93 (dolist (entry load-history) 99 (dolist (entry load-history)