Mercurial > hg > xemacs-beta
comparison src/doc.c @ 5789:72c5d36ba3b6
Make `define-function' accept docstring, as in GNU Emacs.
2014-01-27 Michael Sperber <mike@xemacs.org>
* symbols.c (Fdefine_function): Allow optional `docstring'
argument, as in GNU Emacs.
* lisp.h (Qfunction_documentation): Add extern declaration.
* doc.c (Fdocumentation_property): Move before its use.
(Fdocumentation): Retrieve documentation from `define-function'
docstring for symbols.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Mon, 27 Jan 2014 17:50:57 +0100 |
parents | 2014ff433daf |
children | a216b3c2b09e |
comparison
equal
deleted
inserted
replaced
5788:6a6c89b53c5d | 5789:72c5d36ba3b6 |
---|---|
34 #include "sysfile.h" | 34 #include "sysfile.h" |
35 | 35 |
36 Lisp_Object Vinternal_doc_file_name; | 36 Lisp_Object Vinternal_doc_file_name; |
37 | 37 |
38 Lisp_Object QSsubstitute, Qdefvar; | 38 Lisp_Object QSsubstitute, Qdefvar; |
39 | |
40 Lisp_Object Qfunction_documentation; | |
39 | 41 |
40 /* 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 |
41 information from the documentation file. */ | 43 information from the documentation file. */ |
42 | 44 |
43 static Lisp_Object | 45 static Lisp_Object |
576 } | 578 } |
577 | 579 |
578 return Qnil; | 580 return Qnil; |
579 } | 581 } |
580 | 582 |
583 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /* | |
584 Return the documentation string that is SYMBOL's PROP property. | |
585 This is like `get', but it can refer to strings stored in the | |
586 `doc-directory/DOC' file; and if the value is a string, it is passed | |
587 through `substitute-command-keys'. A non-nil third argument avoids this | |
588 translation. | |
589 */ | |
590 (symbol, prop, raw)) | |
591 { | |
592 /* This function can GC */ | |
593 Lisp_Object doc = Qnil; | |
594 #ifdef I18N3 | |
595 REGISTER Lisp_Object domain; | |
596 #endif | |
597 struct gcpro gcpro1; | |
598 | |
599 GCPRO1 (doc); | |
600 | |
601 doc = Fget (symbol, prop, Qnil); | |
602 if (FIXNUMP (doc)) | |
603 doc = get_doc_string (XFIXNUM (doc) > 0 ? doc : make_fixnum (- XFIXNUM (doc))); | |
604 else if (CONSP (doc)) | |
605 doc = get_doc_string (doc); | |
606 #ifdef I18N3 | |
607 if (!NILP (doc)) | |
608 { | |
609 domain = Fget (symbol, Qvariable_domain, Qnil); | |
610 if (NILP (domain)) | |
611 doc = Fgettext (doc); | |
612 else | |
613 doc = Fdgettext (domain, doc); | |
614 } | |
615 #endif | |
616 if (NILP (raw) && STRINGP (doc)) | |
617 doc = Fsubstitute_command_keys (doc); | |
618 UNGCPRO; | |
619 return doc; | |
620 } | |
621 | |
581 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /* | 622 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /* |
582 Return the documentation string of FUNCTION. | 623 Return the documentation string of FUNCTION. |
583 Unless a non-nil second argument RAW is given, the | 624 Unless a non-nil second argument RAW is given, the |
584 string is passed through `substitute-command-keys'. | 625 string is passed through `substitute-command-keys'. |
585 */ | 626 */ |
586 (function, raw)) | 627 (function, raw)) |
587 { | 628 { |
588 /* This function can GC */ | 629 /* This function can GC */ |
589 Lisp_Object fun; | 630 Lisp_Object fun; |
590 Lisp_Object doc; | 631 Lisp_Object doc; |
632 | |
633 if (SYMBOLP (function)) | |
634 { | |
635 Lisp_Object tem = Fget (function, Qfunction_documentation, Qnil); | |
636 if (!NILP (tem)) | |
637 return Fdocumentation_property (function, Qfunction_documentation, | |
638 raw); | |
639 } | |
591 | 640 |
592 fun = Findirect_function (function); | 641 fun = Findirect_function (function); |
593 | 642 |
594 if (SUBRP (fun)) | 643 if (SUBRP (fun)) |
595 { | 644 { |
674 | 723 |
675 GCPRO1 (doc); | 724 GCPRO1 (doc); |
676 doc = Fsubstitute_command_keys (doc); | 725 doc = Fsubstitute_command_keys (doc); |
677 UNGCPRO; | 726 UNGCPRO; |
678 } | 727 } |
679 return doc; | |
680 } | |
681 | |
682 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /* | |
683 Return the documentation string that is SYMBOL's PROP property. | |
684 This is like `get', but it can refer to strings stored in the | |
685 `doc-directory/DOC' file; and if the value is a string, it is passed | |
686 through `substitute-command-keys'. A non-nil third argument avoids this | |
687 translation. | |
688 */ | |
689 (symbol, prop, raw)) | |
690 { | |
691 /* This function can GC */ | |
692 Lisp_Object doc = Qnil; | |
693 #ifdef I18N3 | |
694 REGISTER Lisp_Object domain; | |
695 #endif | |
696 struct gcpro gcpro1; | |
697 | |
698 GCPRO1 (doc); | |
699 | |
700 doc = Fget (symbol, prop, Qnil); | |
701 if (FIXNUMP (doc)) | |
702 doc = get_doc_string (XFIXNUM (doc) > 0 ? doc : make_fixnum (- XFIXNUM (doc))); | |
703 else if (CONSP (doc)) | |
704 doc = get_doc_string (doc); | |
705 #ifdef I18N3 | |
706 if (!NILP (doc)) | |
707 { | |
708 domain = Fget (symbol, Qvariable_domain, Qnil); | |
709 if (NILP (domain)) | |
710 doc = Fgettext (doc); | |
711 else | |
712 doc = Fdgettext (domain, doc); | |
713 } | |
714 #endif | |
715 if (NILP (raw) && STRINGP (doc)) | |
716 doc = Fsubstitute_command_keys (doc); | |
717 UNGCPRO; | |
718 return doc; | 728 return doc; |
719 } | 729 } |
720 | 730 |
721 | 731 |
722 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /* | 732 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /* |
1297 DEFSUBR (Fsnarf_documentation); | 1307 DEFSUBR (Fsnarf_documentation); |
1298 DEFSUBR (Fverify_documentation); | 1308 DEFSUBR (Fverify_documentation); |
1299 DEFSUBR (Fsubstitute_command_keys); | 1309 DEFSUBR (Fsubstitute_command_keys); |
1300 | 1310 |
1301 DEFSYMBOL (Qdefvar); | 1311 DEFSYMBOL (Qdefvar); |
1312 DEFSYMBOL (Qfunction_documentation); | |
1302 } | 1313 } |
1303 | 1314 |
1304 void | 1315 void |
1305 vars_of_doc (void) | 1316 vars_of_doc (void) |
1306 { | 1317 { |