changeset 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 f32c7f843961
children 0ed907d0f1e9 061e030e3270
files lisp/ChangeLog lisp/cus-face.el lisp/help.el lisp/loadhist.el src/ChangeLog src/eval.c src/symbols.c
diffstat 7 files changed, 51 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Dec 22 12:09:08 2008 +0000
+++ b/lisp/ChangeLog	Mon Dec 22 14:07:48 2008 +0000
@@ -1,3 +1,17 @@
+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.
+
 2008-10-29  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* bytecomp.el (byte-compile-file): Protect encoding from latin-unity.
--- a/lisp/cus-face.el	Mon Dec 22 12:09:08 2008 +0000
+++ b/lisp/cus-face.el	Mon Dec 22 14:07:48 2008 +0000
@@ -50,6 +50,9 @@
 		frames (cdr frames))
 	  (face-display-set face value frame '(custom)))
 	(init-face-from-resources face)))
+    ;; Don't record SPEC until we see it causes no errors.
+    (put face 'face-defface-spec spec)
+    (push (cons 'defface face) current-load-list)
     (when (and doc (null (face-doc-string face)))
       (set-face-doc-string face doc))
     (custom-handle-all-keywords face args 'custom-face)
--- a/lisp/help.el	Mon Dec 22 12:09:08 2008 +0000
+++ b/lisp/help.el	Mon Dec 22 14:07:48 2008 +0000
@@ -1425,7 +1425,7 @@
              nil)))
     (princ "\n")
     (or file-name
-	(setq file-name (symbol-file function)))
+	(setq file-name (symbol-file function 'defun)))
     (when file-name
 	(princ "  -- loaded from \"")
 	(if (not (bufferp standard-output))
@@ -1651,7 +1651,7 @@
 	 (princ (built-in-variable-doc variable))
 	 (princ ".\n")
 	 (require 'hyper-apropos)
-	 (let ((file-name (symbol-file variable))
+	 (let ((file-name (symbol-file variable 'defvar))
 	       opoint e)
 	   (when file-name
 	       (princ "  -- loaded from \"")
--- 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)))))
 
--- a/src/ChangeLog	Mon Dec 22 12:09:08 2008 +0000
+++ b/src/ChangeLog	Mon Dec 22 14:07:48 2008 +0000
@@ -1,3 +1,10 @@
+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. 
+
 2008-12-22  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* faces.c (Fbuilt_in_face_specifiers): 
--- a/src/eval.c	Mon Dec 22 12:09:08 2008 +0000
+++ b/src/eval.c	Mon Dec 22 14:07:48 2008 +0000
@@ -1223,7 +1223,7 @@
 define_function (Lisp_Object name, Lisp_Object defn)
 {
   Ffset (name, defn);
-  LOADHIST_ATTACH (name);
+  LOADHIST_ATTACH (Fcons (Qdefun, name));
   return name;
 }
 
--- a/src/symbols.c	Mon Dec 22 12:09:08 2008 +0000
+++ b/src/symbols.c	Mon Dec 22 14:07:48 2008 +0000
@@ -718,7 +718,7 @@
 {
   /* This function can GC */
   Ffset (symbol, newdef);
-  LOADHIST_ATTACH (symbol);
+  LOADHIST_ATTACH (Fcons (Qdefun, symbol));
   return newdef;
 }