Mercurial > hg > xemacs-beta
comparison src/doc.c @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | abe6d1db359e |
children | 1ccc32a20af4 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
136 } | 136 } |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 /* #### mrb: following STILL completely broken */ | 140 /* #### mrb: following STILL completely broken */ |
141 return_me = make_ext_string ((Bufbyte *) buffer, to - buffer, Qbinary); | 141 return_me = make_ext_string (buffer, to - buffer, Qbinary); |
142 | 142 |
143 done: | 143 done: |
144 if (buffer != buf) /* We must have allocated buffer above */ | 144 if (buffer != buf) /* We must have allocated buffer above */ |
145 xfree (buffer); | 145 xfree (buffer); |
146 return return_me; | 146 return return_me; |
259 return Fread (string); | 259 return Fread (string); |
260 } | 260 } |
261 | 261 |
262 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /* | 262 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /* |
263 Return the documentation string of FUNCTION. | 263 Return the documentation string of FUNCTION. |
264 Unless a non-nil second argument is given, the | 264 Unless a non-nil second argument RAW is given, the |
265 string is passed through `substitute-command-keys'. | 265 string is passed through `substitute-command-keys'. |
266 */ | 266 */ |
267 (function, raw)) | 267 (function, raw)) |
268 { | 268 { |
269 /* This function can GC */ | 269 /* This function can GC */ |
357 This is like `get', but it can refer to strings stored in the | 357 This is like `get', but it can refer to strings stored in the |
358 `doc-directory/DOC' file; and if the value is a string, it is passed | 358 `doc-directory/DOC' file; and if the value is a string, it is passed |
359 through `substitute-command-keys'. A non-nil third argument avoids this | 359 through `substitute-command-keys'. A non-nil third argument avoids this |
360 translation. | 360 translation. |
361 */ | 361 */ |
362 (sym, prop, raw)) | 362 (symbol, prop, raw)) |
363 { | 363 { |
364 /* This function can GC */ | 364 /* This function can GC */ |
365 REGISTER Lisp_Object doc = Qnil; | 365 REGISTER Lisp_Object doc = Qnil; |
366 #ifdef I18N3 | 366 #ifdef I18N3 |
367 REGISTER Lisp_Object domain; | 367 REGISTER Lisp_Object domain; |
368 #endif | 368 #endif |
369 struct gcpro gcpro1; | 369 struct gcpro gcpro1; |
370 | 370 |
371 GCPRO1 (doc); | 371 GCPRO1 (doc); |
372 | 372 |
373 doc = Fget (sym, prop, Qnil); | 373 doc = Fget (symbol, prop, Qnil); |
374 if (INTP (doc)) | 374 if (INTP (doc)) |
375 doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc))); | 375 doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc))); |
376 else if (CONSP (doc)) | 376 else if (CONSP (doc)) |
377 doc = get_doc_string (doc); | 377 doc = get_doc_string (doc); |
378 #ifdef I18N3 | 378 #ifdef I18N3 |
379 if (!NILP (doc)) | 379 if (!NILP (doc)) |
380 { | 380 { |
381 domain = Fget (sym, Qvariable_domain, Qnil); | 381 domain = Fget (symbol, Qvariable_domain, Qnil); |
382 if (NILP (domain)) | 382 if (NILP (domain)) |
383 doc = Fgettext (doc); | 383 doc = Fgettext (doc); |
384 else | 384 else |
385 doc = Fdgettext (domain, doc); | 385 doc = Fdgettext (domain, doc); |
386 } | 386 } |
737 Substitute key descriptions for command names in STRING. | 737 Substitute key descriptions for command names in STRING. |
738 Return a new string which is STRING with substrings of the form \\=\\[COMMAND] | 738 Return a new string which is STRING with substrings of the form \\=\\[COMMAND] |
739 replaced by either: a keystroke sequence that will invoke COMMAND, | 739 replaced by either: a keystroke sequence that will invoke COMMAND, |
740 or "M-x COMMAND" if COMMAND is not on any keys. | 740 or "M-x COMMAND" if COMMAND is not on any keys. |
741 Substrings of the form \\=\\{MAPVAR} are replaced by summaries | 741 Substrings of the form \\=\\{MAPVAR} are replaced by summaries |
742 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap. | 742 \(made by `describe-bindings') of the value of MAPVAR, taken as a keymap. |
743 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR | 743 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR |
744 as the keymap for future \\=\\[COMMAND] substrings. | 744 as the keymap for future \\=\\[COMMAND] substrings. |
745 \\=\\= quotes the following character and is discarded; | 745 \\=\\= quotes the following character and is discarded; |
746 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. | 746 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. |
747 */ | 747 */ |
748 (str)) | 748 (string)) |
749 { | 749 { |
750 /* This function can GC */ | 750 /* This function can GC */ |
751 Bufbyte *buf; | 751 Bufbyte *buf; |
752 int changed = 0; | 752 int changed = 0; |
753 REGISTER Bufbyte *strdata; | 753 REGISTER Bufbyte *strdata; |
754 REGISTER Bufbyte *bufp; | 754 REGISTER Bufbyte *bufp; |
755 Bytecount strlength; | 755 Bytecount strlength; |
756 Bytecount idx; | 756 Bytecount idx; |
757 Bytecount bsize; | 757 Bytecount bsize; |
758 Bufbyte *new; | 758 Bufbyte *new; |
759 Lisp_Object tem; | 759 Lisp_Object tem = Qnil; |
760 Lisp_Object keymap; | 760 Lisp_Object keymap = Qnil; |
761 Lisp_Object name = Qnil; | |
761 Bufbyte *start; | 762 Bufbyte *start; |
762 Bytecount length; | 763 Bytecount length; |
763 Lisp_Object name; | |
764 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 764 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
765 | 765 |
766 if (NILP (str)) | 766 if (NILP (string)) |
767 return Qnil; | 767 return Qnil; |
768 | 768 |
769 CHECK_STRING (str); | 769 CHECK_STRING (string); |
770 tem = Qnil; | 770 GCPRO4 (string, tem, keymap, name); |
771 keymap = Qnil; | |
772 name = Qnil; | |
773 GCPRO4 (str, tem, keymap, name); | |
774 | 771 |
775 /* There is the possibility that the string is not destined for a | 772 /* There is the possibility that the string is not destined for a |
776 translating stream, and it could be argued that we should do the | 773 translating stream, and it could be argued that we should do the |
777 same thing here as in Fformat(), but there are very few times | 774 same thing here as in Fformat(), but there are very few times |
778 when this will be the case and many calls to this function | 775 when this will be the case and many calls to this function |
779 would have to have `gettext' calls added. (I18N3) */ | 776 would have to have `gettext' calls added. (I18N3) */ |
780 str = LISP_GETTEXT (str); | 777 string = LISP_GETTEXT (string); |
781 | 778 |
782 /* KEYMAP is either nil (which means search all the active keymaps) | 779 /* KEYMAP is either nil (which means search all the active keymaps) |
783 or a specified local map (which means search just that and the | 780 or a specified local map (which means search just that and the |
784 global map). If non-nil, it might come from Voverriding_local_map, | 781 global map). If non-nil, it might come from Voverriding_local_map, |
785 or from a \\<mapname> construct in STR itself.. */ | 782 or from a \\<mapname> construct in STRING itself.. */ |
786 #if 0 /* FSFmacs */ | 783 #if 0 /* FSFmacs */ |
787 /* This is really weird and garbagey. If keymap is nil and there's | 784 /* This is really weird and garbagey. If keymap is nil and there's |
788 an overriding-local-map, `where-is-internal' will correctly note | 785 an overriding-local-map, `where-is-internal' will correctly note |
789 this, so there's no reason to do it here. Maybe FSFmacs | 786 this, so there's no reason to do it here. Maybe FSFmacs |
790 `where-is-internal' is broken. */ | 787 `where-is-internal' is broken. */ |
793 if (NILP (keymap)) | 790 if (NILP (keymap)) |
794 keymap = Voverriding_local_map; | 791 keymap = Voverriding_local_map; |
795 */ | 792 */ |
796 #endif | 793 #endif |
797 | 794 |
798 strlength = XSTRING_LENGTH (str); | 795 strlength = XSTRING_LENGTH (string); |
799 bsize = 1 + strlength; | 796 bsize = 1 + strlength; |
800 buf = (Bufbyte *) xmalloc (bsize); | 797 buf = (Bufbyte *) xmalloc (bsize); |
801 bufp = buf; | 798 bufp = buf; |
802 | 799 |
803 /* Have to reset strdata every time GC might be called */ | 800 /* Have to reset strdata every time GC might be called */ |
804 strdata = XSTRING_DATA (str); | 801 strdata = XSTRING_DATA (string); |
805 for (idx = 0; idx < strlength; ) | 802 for (idx = 0; idx < strlength; ) |
806 { | 803 { |
807 Bufbyte *strp = strdata + idx; | 804 Bufbyte *strp = strdata + idx; |
808 | 805 |
809 if (strp[0] != '\\') | 806 if (strp[0] != '\\') |
854 | 851 |
855 tem = Fintern (make_string (start, length), Qnil); | 852 tem = Fintern (make_string (start, length), Qnil); |
856 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil); | 853 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil); |
857 | 854 |
858 #if 0 /* FSFmacs */ | 855 #if 0 /* FSFmacs */ |
859 /* Disregard menu bar bindings; it is positively annoying to | 856 /* Disregard menu bar bindings; it is positively annoying to |
860 mention them when there's no menu bar, and it isn't terribly | 857 mention them when there's no menu bar, and it isn't terribly |
861 useful even when there is a menu bar. */ | 858 useful even when there is a menu bar. */ |
862 if (!NILP (tem)) | 859 if (!NILP (tem)) |
863 { | 860 { |
864 firstkey = Faref (tem, Qzero); | 861 firstkey = Faref (tem, Qzero); |
865 if (EQ (firstkey, Qmenu_bar)) | 862 if (EQ (firstkey, Qmenu_bar)) |
866 tem = Qnil; | 863 tem = Qnil; |
867 } | 864 } |
868 #endif | 865 #endif |
869 | 866 |
870 if (NILP (tem)) /* but not on any keys */ | 867 if (NILP (tem)) /* but not on any keys */ |
871 { | 868 { |
872 new = (Bufbyte *) xrealloc (buf, bsize += 4); | 869 new = (Bufbyte *) xrealloc (buf, bsize += 4); |
883 } | 880 } |
884 } | 881 } |
885 case '{': | 882 case '{': |
886 case '<': | 883 case '<': |
887 { | 884 { |
888 /* #### jump to label `subst_string|subst' crosses | 885 Lisp_Object buffer = Fget_buffer_create (QSsubstitute); |
889 initialization of `buffer|_buf' */ | 886 struct buffer *buf_ = XBUFFER (buffer); |
890 Lisp_Object buffer; | |
891 struct buffer *buf_; | |
892 | |
893 buffer = Fget_buffer_create (QSsubstitute); | |
894 buf_ = XBUFFER (buffer); | |
895 | 887 |
896 Fbuffer_disable_undo (buffer); | 888 Fbuffer_disable_undo (buffer); |
897 Ferase_buffer (buffer); | 889 Ferase_buffer (buffer); |
898 | 890 |
899 /* \{foo} is replaced with a summary of keymap (symbol-value foo). | 891 /* \{foo} is replaced with a summary of keymap (symbol-value foo). |
924 tem = get_keymap (tem, 0, 1); | 916 tem = get_keymap (tem, 0, 1); |
925 } | 917 } |
926 | 918 |
927 if (NILP (tem)) | 919 if (NILP (tem)) |
928 { | 920 { |
929 char boof[255], *b = boof; | 921 buffer_insert_c_string (buf_, "(uses keymap \""); |
930 *b++ = '\n'; | 922 buffer_insert_lisp_string (buf_, Fsymbol_name (name)); |
931 /* #### This sprintf() is potentially dangerous! */ | 923 buffer_insert_c_string (buf_, "\", which is not currently defined) "); |
932 sprintf (b, GETTEXT ( | |
933 "Uses keymap \"%s\", which is not currently defined."), | |
934 (char *) XSTRING_DATA (Fsymbol_name (name))); | |
935 b += strlen (b); | |
936 *b++ = '\n'; | |
937 *b++ = 0; | |
938 buffer_insert_c_string (buf_, boof); | |
939 | 924 |
940 if (start[-1] == '<') keymap = Qnil; | 925 if (start[-1] == '<') keymap = Qnil; |
941 } | 926 } |
942 else if (start[-1] == '<') | 927 else if (start[-1] == '<') |
943 keymap = tem; | 928 keymap = tem; |
945 describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer); | 930 describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer); |
946 | 931 |
947 tem = make_string_from_buffer (buf_, BUF_BEG (buf_), | 932 tem = make_string_from_buffer (buf_, BUF_BEG (buf_), |
948 BUF_Z (buf_) - BUF_BEG (buf_)); | 933 BUF_Z (buf_) - BUF_BEG (buf_)); |
949 Ferase_buffer (buffer); | 934 Ferase_buffer (buffer); |
950 goto subst_string; | |
951 | |
952 subst_string: | |
953 start = XSTRING_DATA (tem); | |
954 length = XSTRING_LENGTH (tem); | |
955 subst: | |
956 bsize += length; | |
957 new = (Bufbyte *) xrealloc (buf, bsize); | |
958 bufp += new - buf; | |
959 buf = new; | |
960 memcpy (bufp, start, length); | |
961 bufp += length; | |
962 | |
963 /* Reset STRDATA in case gc relocated it. */ | |
964 strdata = XSTRING_DATA (str); | |
965 | |
966 break; | |
967 } | 935 } |
936 goto subst_string; | |
937 | |
938 subst_string: | |
939 start = XSTRING_DATA (tem); | |
940 length = XSTRING_LENGTH (tem); | |
941 subst: | |
942 bsize += length; | |
943 new = (Bufbyte *) xrealloc (buf, bsize); | |
944 bufp += new - buf; | |
945 buf = new; | |
946 memcpy (bufp, start, length); | |
947 bufp += length; | |
948 | |
949 /* Reset STRDATA in case gc relocated it. */ | |
950 strdata = XSTRING_DATA (string); | |
951 | |
952 break; | |
968 } | 953 } |
969 } | 954 } |
970 | 955 |
971 if (changed) /* don't bother if nothing substituted */ | 956 if (changed) /* don't bother if nothing substituted */ |
972 tem = make_string (buf, bufp - buf); | 957 tem = make_string (buf, bufp - buf); |
973 else | 958 else |
974 tem = str; | 959 tem = string; |
975 xfree (buf); | 960 xfree (buf); |
976 UNGCPRO; | 961 UNGCPRO; |
977 return tem; | 962 return tem; |
978 } | 963 } |
979 | 964 |