changeset: 4367:69e6352406f0393738f99a6d250c351e7016f47b
parent: 4365:c9ab656691c04f41c53df820c0a83e4ee36f5177
user: Aidan Kehoe <kehoea(a)parhasard.net>
date: Sun Dec 30 15:33:13 2007 +0100
files: lisp/ChangeLog lisp/loadhist.el src/ChangeLog src/doc.c
description:
Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
src/ChangeLog addition:
2007-12-30 Aidan Kehoe <kehoea(a)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(a)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.
diff -r c9ab656691c04f41c53df820c0a83e4ee36f5177 -r
69e6352406f0393738f99a6d250c351e7016f47b lisp/ChangeLog
--- a/lisp/ChangeLog Thu Dec 27 13:22:26 2007 +0100
+++ b/lisp/ChangeLog Sun Dec 30 15:33:13 2007 +0100
@@ -1,3 +1,14 @@ 2007-12-25 Aidan Kehoe <kehoea@parhasa
+2007-12-30 Aidan Kehoe <kehoea(a)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.
+
2007-12-25 Aidan Kehoe <kehoea(a)parhasard.net>
* glyphs.el (init-glyphs):
diff -r c9ab656691c04f41c53df820c0a83e4ee36f5177 -r
69e6352406f0393738f99a6d250c351e7016f47b lisp/loadhist.el
--- a/lisp/loadhist.el Thu Dec 27 13:22:26 2007 +0100
+++ b/lisp/loadhist.el Sun Dec 30 15:33:13 2007 +0100
@@ -25,6 +25,8 @@
;;; Synched up with: FSF 20.2.
+;; #### Sync this file!
+
;;; Commentary:
;; This file is dumped with XEmacs.
@@ -37,19 +39,36 @@
;; load-history is a list of entries that look like this:
;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline)
...)
-(defun symbol-file (sym)
+(defun symbol-file (sym &optional type)
"Return the input source from which SYM was loaded.
-This is a file name, or nil if the source was a buffer with no associated file."
+This is a file name, or nil if the source was a buffer with no associated file.
+
+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.
+
+#### For the moment the difference is not implemented for non-autoloaded
+Lisp symbols."
(interactive "SFind source file for symbol: ") ; XEmacs
(block look-up-symbol-file
- (dolist (entry load-history)
- (when (memq sym (cdr entry))
- (return-from look-up-symbol-file (car entry))))
- (when (or (and (boundp sym) (built-in-variable-type sym))
- (and (fboundp sym) (subrp (symbol-function sym))))
- (let ((built-in-file (built-in-symbol-file sym)))
- (if built-in-file
- (concat source-directory "/src/" built-in-file))))))
+ (let (built-in-file autoload-cons)
+ (when (and
+ (eq 'autoload
+ (car-safe (setq autoload-cons
+ (and (fboundp sym)
+ (symbol-function sym)))))
+ (or (and (or (null type) (eq 'defvar type))
+ (eq (fifth autoload-cons) 'keymap))
+ (and (or (null type) (eq 'defvar type))
+ (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))))
+ (setq built-in-file (built-in-symbol-file sym type))
+ (if built-in-file (concat source-directory "/src/" built-in-file)))))
(defun feature-symbols (feature)
"Return the file and list of symbols associated with a given FEATURE."
diff -r c9ab656691c04f41c53df820c0a83e4ee36f5177 -r
69e6352406f0393738f99a6d250c351e7016f47b src/ChangeLog
--- a/src/ChangeLog Thu Dec 27 13:22:26 2007 +0100
+++ b/src/ChangeLog Sun Dec 30 15:33:13 2007 +0100
@@ -1,3 +1,10 @@ 2007-12-24 Aidan Kehoe <kehoea@parhasa
+2007-12-30 Aidan Kehoe <kehoea(a)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.
+
2007-12-24 Aidan Kehoe <kehoea(a)parhasard.net>
* event-xlike-inc.c (x_keysym_to_character):
diff -r c9ab656691c04f41c53df820c0a83e4ee36f5177 -r
69e6352406f0393738f99a6d250c351e7016f47b src/doc.c
--- 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 @@ Boston, MA 02111-1307, USA. */
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 @@ weird_doc (Lisp_Object sym, const CIbyte
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 @@ Don't use this. Use the more general `s
(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 @@ syms_of_doc (void)
DEFSUBR (Fsnarf_documentation);
DEFSUBR (Fverify_documentation);
DEFSUBR (Fsubstitute_command_keys);
+
+ DEFSYMBOL (Qdefvar);
}
void
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches