diff 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
line wrap: on
line diff
--- a/lisp/loadhist.el	Mon Dec 22 12:09:08 2008 +0000
+++ b/lisp/loadhist.el	Mon Dec 22 14:07:48 2008 +0000
@@ -48,11 +48,12 @@
 are acceptable.
 If TYPE is `defvar', then variable definitions are acceptable.
 
-#### For the moment the difference is not implemented for non-autoloaded
-Lisp symbols."
+`defface' specifies a face definition only, and for the moment, it won't
+return faces created with `make-face' or `copy-face', just those created
+with `defface' and `custom-declare-face'."
   (interactive "SFind source file for symbol: ") ; XEmacs
   (block look-up-symbol-file
-    (let (built-in-file autoload-cons)
+    (let (built-in-file autoload-cons symbol-details)
       (when (and 
              (eq 'autoload
                  (car-safe (setq autoload-cons
@@ -64,9 +65,25 @@
                     (memq (fifth autoload-cons) '(nil macro)))))
         (return-from look-up-symbol-file
           (locate-library (second autoload-cons))))
-      (dolist (entry load-history)
-        (when (memq sym (cdr entry))
-          (return-from look-up-symbol-file (car entry))))
+      (cond ((eq 'defvar type)
+             ;; Load history entries corresponding to variables are just
+             ;; symbols.
+             (dolist (entry load-history)
+               (when (memq sym (cdr entry))
+                 (return-from look-up-symbol-file (car entry)))))
+            ((not (null type))
+             ;; Non-variables have the type stored as the car of the entry. 
+             (dolist (entry load-history)
+               (when (and (setq symbol-details (rassq sym (cdr entry)))
+                          (eq type (car symbol-details)))
+                 (return-from look-up-symbol-file (car entry)))))
+            (t
+             ;; If TYPE hasn't been specified, we need to check both for
+             ;; variables and other symbols.
+             (dolist (entry load-history)
+               (when (or (memq sym (cdr entry))
+                         (rassq sym (cdr entry)))
+                 (return-from look-up-symbol-file (car entry))))))
       (setq built-in-file (built-in-symbol-file sym type))
       (if built-in-file (concat source-directory "/src/" built-in-file)))))