Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
4365:c9ab656691c0 | 4367:69e6352406f0 |
---|---|
35 #include "lstream.h" | 35 #include "lstream.h" |
36 #include "sysfile.h" | 36 #include "sysfile.h" |
37 | 37 |
38 Lisp_Object Vinternal_doc_file_name; | 38 Lisp_Object Vinternal_doc_file_name; |
39 | 39 |
40 Lisp_Object QSsubstitute; | 40 Lisp_Object QSsubstitute, Qdefvar; |
41 | 41 |
42 /* Work out what source file a function or variable came from, taking the | 42 /* Work out what source file a function or variable came from, taking the |
43 information from the documentation file. */ | 43 information from the documentation file. */ |
44 | 44 |
45 static Lisp_Object | 45 static Lisp_Object |
497 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return; | 497 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return; |
498 message ("Note: Strange doc (%s) for %s %s @ %d", | 498 message ("Note: Strange doc (%s) for %s %s @ %d", |
499 weirdness, type, XSTRING_DATA (XSYMBOL (sym)->name), pos); | 499 weirdness, type, XSTRING_DATA (XSYMBOL (sym)->name), pos); |
500 } | 500 } |
501 | 501 |
502 DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 1, 0, /* | 502 DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 2, 0, /* |
503 Return the C source file built-in symbol SYM comes from. | 503 Return the C source file built-in symbol SYM comes from. |
504 Don't use this. Use the more general `symbol-file' (q.v.) instead. | 504 Don't use this. Use the more general `symbol-file' (q.v.) instead. |
505 | |
506 If TYPE is nil or omitted, any kind of definition is acceptable. | |
507 If TYPE is `defun', then function, subr, special form or macro definitions | |
508 are acceptable. | |
509 If TYPE is `defvar', then variable definitions are acceptable. | |
505 */ | 510 */ |
506 (symbol)) | 511 (symbol, type)) |
507 { | 512 { |
508 /* This function can GC */ | 513 /* This function can GC */ |
509 Lisp_Object fun; | 514 Lisp_Object fun; |
510 Lisp_Object filename = Qnil; | 515 Lisp_Object filename = Qnil; |
511 | 516 |
512 if (EQ(Ffboundp(symbol), Qt)) | 517 if (EQ(Ffboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefun))) |
513 { | 518 { |
514 fun = Findirect_function (symbol); | 519 fun = Findirect_function (symbol); |
515 | 520 |
516 if (SUBRP (fun)) | 521 if (SUBRP (fun) || (CONSP(fun) && (EQ (Qmacro, Fcar_safe (fun))) |
522 && (fun = Fcdr_safe (fun)) | |
523 && (SUBRP (fun)))) | |
517 { | 524 { |
518 if (XSUBR (fun)->doc == 0) | 525 if (XSUBR (fun)->doc == 0) |
519 return Qnil; | 526 return Qnil; |
520 | 527 |
521 if ((EMACS_INT) XSUBR (fun)->doc >= 0) | 528 if ((EMACS_INT) XSUBR (fun)->doc >= 0) |
527 else | 534 else |
528 filename = get_object_file_name | 535 filename = get_object_file_name |
529 (make_int (- (EMACS_INT) XSUBR (fun)->doc)); | 536 (make_int (- (EMACS_INT) XSUBR (fun)->doc)); |
530 } | 537 } |
531 } | 538 } |
532 else if (EQ(Fboundp(symbol), Qt)) | 539 else if (EQ(Fboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefvar))) |
533 { | 540 { |
534 Lisp_Object doc_offset = Fget (symbol, Qvariable_documentation, Qnil); | 541 Lisp_Object doc_offset = Fget (symbol, Qvariable_documentation, Qnil); |
535 | 542 |
536 if (!NILP(doc_offset)) | 543 if (!NILP(doc_offset)) |
537 { | 544 { |
1271 DEFSUBR (Fdocumentation); | 1278 DEFSUBR (Fdocumentation); |
1272 DEFSUBR (Fdocumentation_property); | 1279 DEFSUBR (Fdocumentation_property); |
1273 DEFSUBR (Fsnarf_documentation); | 1280 DEFSUBR (Fsnarf_documentation); |
1274 DEFSUBR (Fverify_documentation); | 1281 DEFSUBR (Fverify_documentation); |
1275 DEFSUBR (Fsubstitute_command_keys); | 1282 DEFSUBR (Fsubstitute_command_keys); |
1283 | |
1284 DEFSYMBOL (Qdefvar); | |
1276 } | 1285 } |
1277 | 1286 |
1278 void | 1287 void |
1279 vars_of_doc (void) | 1288 vars_of_doc (void) |
1280 { | 1289 { |