diff src/doc.c @ 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 9b8943d0d12a
children 751d82f59283
line wrap: on
line diff
--- a/src/doc.c	Thu Dec 27 13:22:26 2007 +0100
+++ b/src/doc.c	Sun Dec 30 15:33:13 2007 +0100
@@ -37,7 +37,7 @@
 
 Lisp_Object Vinternal_doc_file_name;
 
-Lisp_Object QSsubstitute;
+Lisp_Object QSsubstitute, Qdefvar;
 
 /* Work out what source file a function or variable came from, taking the
    information from the documentation file. */
@@ -499,21 +499,28 @@
            weirdness, type, XSTRING_DATA (XSYMBOL (sym)->name), pos);
 }
 
-DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 1, 0, /*
+DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 2, 0, /*
 Return the C source file built-in symbol SYM comes from. 
 Don't use this.  Use the more general `symbol-file' (q.v.) instead. 
+
+If TYPE is nil or omitted, any kind of definition is acceptable. 
+If TYPE is `defun', then function, subr, special form or macro definitions
+are acceptable.
+If TYPE is `defvar', then variable definitions are acceptable.
 */
-       (symbol))
+       (symbol, type))
 {
   /* This function can GC */
   Lisp_Object fun;
   Lisp_Object filename = Qnil;
 
-  if (EQ(Ffboundp(symbol), Qt))
+  if (EQ(Ffboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefun)))
     {
       fun = Findirect_function (symbol);
 
-      if (SUBRP (fun))
+      if (SUBRP (fun) || (CONSP(fun) && (EQ (Qmacro, Fcar_safe (fun)))
+                          && (fun = Fcdr_safe (fun))
+                          && (SUBRP (fun))))
 	{
 	  if (XSUBR (fun)->doc == 0)
 	    return Qnil;
@@ -529,7 +536,7 @@
 	      (make_int (- (EMACS_INT) XSUBR (fun)->doc));
 	}
     }
-  else if (EQ(Fboundp(symbol), Qt))
+  else if (EQ(Fboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefvar)))
     {
       Lisp_Object doc_offset = Fget (symbol, Qvariable_documentation, Qnil);
 
@@ -1273,6 +1280,8 @@
   DEFSUBR (Fsnarf_documentation);
   DEFSUBR (Fverify_documentation);
   DEFSUBR (Fsubstitute_command_keys);
+
+  DEFSYMBOL (Qdefvar);
 }
 
 void