comparison lisp/loadhist.el @ 4535:69a1eda3da06

Distinguish vars and functions in #'symbol-file, #'describe-{function,variable} lisp/ChangeLog addition: 2008-12-22 Aidan Kehoe <kehoea@parhasard.net> * loadhist.el (symbol-file): Add support for differentiating between variables and functions to #'symbol-file. * help.el (describe-function-1): (describe-variable): Call #'symbol-function explicitly with a 'defun or 'defvar argument, depending on whether we're looking for a variable or a function. * cus-face.el (custom-declare-face): Record information about the face in the load history; code taken from GNU, pre-GPLv3 revision 1.45. src/ChangeLog addition: 2008-12-22 Aidan Kehoe <kehoea@parhasard.net> * symbols.c (Fdefine_function): * eval.c (define_function): Record explicitly that we're defining a function in the load history, in both these files.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 22 Dec 2008 14:07:48 +0000
parents 69e6352406f0
children 061e030e3270
comparison
equal deleted inserted replaced
4534:f32c7f843961 4535:69a1eda3da06
46 If TYPE is nil or omitted, any kind of definition is acceptable. 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 47 If TYPE is `defun', then function, subr, special form or macro definitions
48 are acceptable. 48 are acceptable.
49 If TYPE is `defvar', then variable definitions are acceptable. 49 If TYPE is `defvar', then variable definitions are acceptable.
50 50
51 #### For the moment the difference is not implemented for non-autoloaded 51 `defface' specifies a face definition only, and for the moment, it won't
52 Lisp symbols." 52 return faces created with `make-face' or `copy-face', just those created
53 with `defface' and `custom-declare-face'."
53 (interactive "SFind source file for symbol: ") ; XEmacs 54 (interactive "SFind source file for symbol: ") ; XEmacs
54 (block look-up-symbol-file 55 (block look-up-symbol-file
55 (let (built-in-file autoload-cons) 56 (let (built-in-file autoload-cons symbol-details)
56 (when (and 57 (when (and
57 (eq 'autoload 58 (eq 'autoload
58 (car-safe (setq autoload-cons 59 (car-safe (setq autoload-cons
59 (and (fboundp sym) 60 (and (fboundp sym)
60 (symbol-function sym))))) 61 (symbol-function sym)))))
62 (eq (fifth autoload-cons) 'keymap)) 63 (eq (fifth autoload-cons) 'keymap))
63 (and (or (null type) (eq 'defvar type)) 64 (and (or (null type) (eq 'defvar type))
64 (memq (fifth autoload-cons) '(nil macro))))) 65 (memq (fifth autoload-cons) '(nil macro)))))
65 (return-from look-up-symbol-file 66 (return-from look-up-symbol-file
66 (locate-library (second autoload-cons)))) 67 (locate-library (second autoload-cons))))
67 (dolist (entry load-history) 68 (cond ((eq 'defvar type)
68 (when (memq sym (cdr entry)) 69 ;; Load history entries corresponding to variables are just
69 (return-from look-up-symbol-file (car entry)))) 70 ;; symbols.
71 (dolist (entry load-history)
72 (when (memq sym (cdr entry))
73 (return-from look-up-symbol-file (car entry)))))
74 ((not (null type))
75 ;; Non-variables have the type stored as the car of the entry.
76 (dolist (entry load-history)
77 (when (and (setq symbol-details (rassq sym (cdr entry)))
78 (eq type (car symbol-details)))
79 (return-from look-up-symbol-file (car entry)))))
80 (t
81 ;; If TYPE hasn't been specified, we need to check both for
82 ;; variables and other symbols.
83 (dolist (entry load-history)
84 (when (or (memq sym (cdr entry))
85 (rassq sym (cdr entry)))
86 (return-from look-up-symbol-file (car entry))))))
70 (setq built-in-file (built-in-symbol-file sym type)) 87 (setq built-in-file (built-in-symbol-file sym type))
71 (if built-in-file (concat source-directory "/src/" built-in-file))))) 88 (if built-in-file (concat source-directory "/src/" built-in-file)))))
72 89
73 (defun feature-symbols (feature) 90 (defun feature-symbols (feature)
74 "Return the file and list of symbols associated with a given FEATURE." 91 "Return the file and list of symbols associated with a given FEATURE."