comparison lisp/loadhist.el @ 4367:69e6352406f0

Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg. src/ChangeLog addition: 2007-12-30 Aidan Kehoe <kehoea@parhasard.net> * doc.c (Fbuilt_in_symbol_file): Take a new TYPE argument, specifying whether the function or variable definition of the symbol should be searched for. Handle built-in macros correctly. lisp/ChangeLog addition: 2007-12-30 Aidan Kehoe <kehoea@parhasard.net> * loadhist.el (symbol-file): Accept a new TYPE argument, compatible with GNU, saying whether function or variable definitions should be searched for. Implement the functionality for autoloads, handling TYPE correctly. Pass the TYPE argument to built-in-symbol-file correctly. Document that TYPE is not implemented for non-autoloaded Lisp definitions. Our load-history doesn't have the relevant metadata.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 30 Dec 2007 15:33:13 +0100
parents 1ee424086c62
children 69a1eda3da06
comparison
equal deleted inserted replaced
4365:c9ab656691c0 4367:69e6352406f0
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; 02111-1307, USA. 24 ;; 02111-1307, USA.
25 25
26 ;;; Synched up with: FSF 20.2. 26 ;;; Synched up with: FSF 20.2.
27 27
28 ;; #### Sync this file!
29
28 ;;; Commentary: 30 ;;; Commentary:
29 31
30 ;; This file is dumped with XEmacs. 32 ;; This file is dumped with XEmacs.
31 33
32 ;; These functions exploit the load-history system variable. 34 ;; These functions exploit the load-history system variable.
35 ;;; Code: 37 ;;; Code:
36 38
37 ;; load-history is a list of entries that look like this: 39 ;; load-history is a list of entries that look like this:
38 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...) 40 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...)
39 41
40 (defun symbol-file (sym) 42 (defun symbol-file (sym &optional type)
41 "Return the input source from which SYM was loaded. 43 "Return the input source from which SYM was loaded.
42 This is a file name, or nil if the source was a buffer with no associated file." 44 This is a file name, or nil if the source was a buffer with no associated file.
45
46 If TYPE is nil or omitted, any kind of definition is acceptable.
47 If TYPE is `defun', then function, subr, special form or macro definitions
48 are acceptable.
49 If TYPE is `defvar', then variable definitions are acceptable.
50
51 #### For the moment the difference is not implemented for non-autoloaded
52 Lisp symbols."
43 (interactive "SFind source file for symbol: ") ; XEmacs 53 (interactive "SFind source file for symbol: ") ; XEmacs
44 (block look-up-symbol-file 54 (block look-up-symbol-file
45 (dolist (entry load-history) 55 (let (built-in-file autoload-cons)
46 (when (memq sym (cdr entry)) 56 (when (and
47 (return-from look-up-symbol-file (car entry)))) 57 (eq 'autoload
48 (when (or (and (boundp sym) (built-in-variable-type sym)) 58 (car-safe (setq autoload-cons
49 (and (fboundp sym) (subrp (symbol-function sym)))) 59 (and (fboundp sym)
50 (let ((built-in-file (built-in-symbol-file sym))) 60 (symbol-function sym)))))
51 (if built-in-file 61 (or (and (or (null type) (eq 'defvar type))
52 (concat source-directory "/src/" built-in-file)))))) 62 (eq (fifth autoload-cons) 'keymap))
63 (and (or (null type) (eq 'defvar type))
64 (memq (fifth autoload-cons) '(nil macro)))))
65 (return-from look-up-symbol-file
66 (locate-library (second autoload-cons))))
67 (dolist (entry load-history)
68 (when (memq sym (cdr entry))
69 (return-from look-up-symbol-file (car entry))))
70 (setq built-in-file (built-in-symbol-file sym type))
71 (if built-in-file (concat source-directory "/src/" built-in-file)))))
53 72
54 (defun feature-symbols (feature) 73 (defun feature-symbols (feature)
55 "Return the file and list of symbols associated with a given FEATURE." 74 "Return the file and list of symbols associated with a given FEATURE."
56 (let ((pair `(provide . ,feature))) 75 (let ((pair `(provide . ,feature)))
57 (dolist (entry load-history) 76 (dolist (entry load-history)