comparison src/doc.c @ 219:262b8bb4a523 r20-4b8

Import from CVS: tag r20-4b8
author cvs
date Mon, 13 Aug 2007 10:09:35 +0200
parents d44af0c54775
children 0e522484dd2a
comparison
equal deleted inserted replaced
218:c9f226976f56 219:262b8bb4a523
33 33
34 #include "sysfile.h" 34 #include "sysfile.h"
35 35
36 36
37 Lisp_Object Vdoc_file_name; 37 Lisp_Object Vdoc_file_name;
38
39 Lisp_Object QSsubstitute;
38 40
39 /* Read and return doc string from open file descriptor FD 41 /* Read and return doc string from open file descriptor FD
40 at position POSITION. Does not close the file. Returns 42 at position POSITION. Does not close the file. Returns
41 string; or if error, returns a cons holding the error 43 string; or if error, returns a cons holding the error
42 data to pass to Fsignal. NAME_NONRELOC and NAME_RELOC 44 data to pass to Fsignal. NAME_NONRELOC and NAME_RELOC
872 } 874 }
873 } 875 }
874 case '{': 876 case '{':
875 case '<': 877 case '<':
876 { 878 {
879 Lisp_Object buffer = Fget_buffer_create (QSsubstitute);
880 struct buffer *buf_ = XBUFFER (buffer);
881
882 Fbuffer_disable_undo (buffer);
883 Ferase_buffer (buffer);
884
877 /* \{foo} is replaced with a summary of keymap (symbol-value foo). 885 /* \{foo} is replaced with a summary of keymap (symbol-value foo).
878 \<foo> just sets the keymap used for \[cmd]. */ 886 \<foo> just sets the keymap used for \[cmd]. */
879 struct buffer *oldbuf;
880
881 changed = 1; 887 changed = 1;
882 idx += 2; /* skip \{ or \< */ 888 idx += 2; /* skip \{ or \< */
883 strp += 2; 889 strp += 2;
884 start = strp; 890 start = strp;
885 891
902 tem = Fsymbol_value (name); 908 tem = Fsymbol_value (name);
903 if (! NILP (tem)) 909 if (! NILP (tem))
904 tem = get_keymap (tem, 0, 1); 910 tem = get_keymap (tem, 0, 1);
905 } 911 }
906 912
907 /* Now switch to a temp buffer. */
908 oldbuf = current_buffer;
909 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
910
911 if (NILP (tem)) 913 if (NILP (tem))
912 { 914 {
913 char boof[255], *b = boof; 915 char boof[255], *b = boof;
914 *b++ = '\n'; 916 *b++ = '\n';
915 sprintf (b, GETTEXT ( 917 sprintf (b, GETTEXT (
916 "Uses keymap \"%s\", which is not currently defined."), 918 "Uses keymap \"%s\", which is not currently defined."),
917 (char *) XSTRING_DATA (Fsymbol_name (name))); 919 (char *) XSTRING_DATA (Fsymbol_name (name)));
918 b += strlen (b); 920 b += strlen (b);
919 *b++ = '\n'; 921 *b++ = '\n';
920 *b++ = 0; 922 *b++ = 0;
921 buffer_insert_c_string (current_buffer, boof); 923 buffer_insert_c_string (buf_, boof);
922 924
923 if (start[-1] == '<') keymap = Qnil; 925 if (start[-1] == '<') keymap = Qnil;
924 } 926 }
925 else if (start[-1] == '<') 927 else if (start[-1] == '<')
926 keymap = tem; 928 keymap = tem;
927 else 929 else
928 describe_map_tree (tem, 1, Qnil, Qnil, 0); 930 describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer);
929 tem = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ()); 931
930 Ferase_buffer (Fcurrent_buffer ()); 932 tem = make_string_from_buffer (buf_, BUF_BEG (buf_),
931 set_buffer_internal (oldbuf); 933 BUF_Z (buf_) - BUF_BEG (buf_));
934 Ferase_buffer (buffer);
932 goto subst_string; 935 goto subst_string;
933 936
934 subst_string: 937 subst_string:
935 start = XSTRING_DATA (tem); 938 start = XSTRING_DATA (tem);
936 length = XSTRING_LENGTH (tem); 939 length = XSTRING_LENGTH (tem);
979 { 982 {
980 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name /* 983 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name /*
981 Name of file containing documentation strings of built-in symbols. 984 Name of file containing documentation strings of built-in symbols.
982 */ ); 985 */ );
983 Vdoc_file_name = Qnil; 986 Vdoc_file_name = Qnil;
984 } 987
988 QSsubstitute = build_string (" *substitute*");
989 staticpro (&QSsubstitute);
990 }