Mercurial > emacs
comparison src/lread.c @ 22420:cb77a5a6a629
(readevalloop): New arg READFUN. Callers changed.
(Feval_region): New arg READ_FUNCTION.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 10 Jun 1998 04:13:57 +0000 |
parents | 2b81c3b8f0c8 |
children | 329fe9a2bdb8 |
comparison
equal
deleted
inserted
replaced
22419:3967db186db6 | 22420:cb77a5a6a629 |
---|---|
697 specbind (Qload_file_name, found); | 697 specbind (Qload_file_name, found); |
698 specbind (Qinhibit_file_name_operation, Qnil); | 698 specbind (Qinhibit_file_name_operation, Qnil); |
699 load_descriptor_list | 699 load_descriptor_list |
700 = Fcons (make_number (fileno (stream)), load_descriptor_list); | 700 = Fcons (make_number (fileno (stream)), load_descriptor_list); |
701 load_in_progress++; | 701 load_in_progress++; |
702 readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil); | 702 readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil, Qnil); |
703 unbind_to (count, Qnil); | 703 unbind_to (count, Qnil); |
704 | 704 |
705 /* Run any load-hooks for this file. */ | 705 /* Run any load-hooks for this file. */ |
706 temp = Fassoc (file, Vafter_load_alist); | 706 temp = Fassoc (file, Vafter_load_alist); |
707 if (!NILP (temp)) | 707 if (!NILP (temp)) |
1019 load_convert_to_unibyte = ! NILP (old); | 1019 load_convert_to_unibyte = ! NILP (old); |
1020 return Qnil; | 1020 return Qnil; |
1021 } | 1021 } |
1022 | 1022 |
1023 /* UNIBYTE specifies how to set load_convert_to_unibyte | 1023 /* UNIBYTE specifies how to set load_convert_to_unibyte |
1024 for this invocation. */ | 1024 for this invocation. |
1025 READFUN, if non-nil, is used instead of `read'. */ | |
1025 | 1026 |
1026 static void | 1027 static void |
1027 readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte) | 1028 readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, readfun) |
1028 Lisp_Object readcharfun; | 1029 Lisp_Object readcharfun; |
1029 FILE *stream; | 1030 FILE *stream; |
1030 Lisp_Object sourcename; | 1031 Lisp_Object sourcename; |
1031 Lisp_Object (*evalfun) (); | 1032 Lisp_Object (*evalfun) (); |
1032 int printflag; | 1033 int printflag; |
1033 Lisp_Object unibyte; | 1034 Lisp_Object unibyte, readfun; |
1034 { | 1035 { |
1035 register int c; | 1036 register int c; |
1036 register Lisp_Object val; | 1037 register Lisp_Object val; |
1037 int count = specpdl_ptr - specpdl; | 1038 int count = specpdl_ptr - specpdl; |
1038 struct gcpro gcpro1; | 1039 struct gcpro gcpro1; |
1081 } | 1082 } |
1082 else | 1083 else |
1083 { | 1084 { |
1084 UNREAD (c); | 1085 UNREAD (c); |
1085 read_objects = Qnil; | 1086 read_objects = Qnil; |
1086 if (NILP (Vload_read_function)) | 1087 if (! NILP (readfun)) |
1088 val = call1 (readfun, readcharfun); | |
1089 else if (! NILP (Vload_read_function)) | |
1090 val = call1 (Vload_read_function, readcharfun); | |
1091 else | |
1087 val = read0 (readcharfun); | 1092 val = read0 (readcharfun); |
1088 else | |
1089 val = call1 (Vload_read_function, readcharfun); | |
1090 } | 1093 } |
1091 | 1094 |
1092 val = (*evalfun) (val); | 1095 val = (*evalfun) (val); |
1093 if (printflag) | 1096 if (printflag) |
1094 { | 1097 { |
1141 filename = XBUFFER (buf)->filename; | 1144 filename = XBUFFER (buf)->filename; |
1142 | 1145 |
1143 specbind (Qstandard_output, tem); | 1146 specbind (Qstandard_output, tem); |
1144 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1147 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
1145 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | 1148 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); |
1146 readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte); | 1149 readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte, Qnil); |
1147 unbind_to (count, Qnil); | 1150 unbind_to (count, Qnil); |
1148 | 1151 |
1149 return Qnil; | 1152 return Qnil; |
1150 } | 1153 } |
1151 | 1154 |
1171 tem = printflag; | 1174 tem = printflag; |
1172 specbind (Qstandard_output, tem); | 1175 specbind (Qstandard_output, tem); |
1173 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1176 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
1174 SET_PT (BEGV); | 1177 SET_PT (BEGV); |
1175 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, | 1178 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
1176 !NILP (printflag), Qnil); | 1179 !NILP (printflag), Qnil, Qnil); |
1177 return unbind_to (count, Qnil); | 1180 return unbind_to (count, Qnil); |
1178 } | 1181 } |
1179 #endif | 1182 #endif |
1180 | 1183 |
1181 DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", | 1184 DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r", |
1182 "Execute the region as Lisp code.\n\ | 1185 "Execute the region as Lisp code.\n\ |
1183 When called from programs, expects two arguments,\n\ | 1186 When called from programs, expects two arguments,\n\ |
1184 giving starting and ending indices in the current buffer\n\ | 1187 giving starting and ending indices in the current buffer\n\ |
1185 of the text to be executed.\n\ | 1188 of the text to be executed.\n\ |
1186 Programs can pass third argument PRINTFLAG which controls output:\n\ | 1189 Programs can pass third argument PRINTFLAG which controls output:\n\ |
1187 nil means discard it; anything else is stream for printing it.\n\ | 1190 nil means discard it; anything else is stream for printing it.\n\ |
1191 Also the fourth argument READ-FUNCTION, if non-nil, is used\n\ | |
1192 instead of `read' to read each expression. It gets one argument\n\ | |
1193 which is the input stream for reading characters.\n\ | |
1188 \n\ | 1194 \n\ |
1189 This function does not move point.") | 1195 This function does not move point.") |
1190 (start, end, printflag) | 1196 (start, end, printflag, read_function) |
1191 Lisp_Object start, end, printflag; | 1197 Lisp_Object start, end, printflag, read_function; |
1192 { | 1198 { |
1193 int count = specpdl_ptr - specpdl; | 1199 int count = specpdl_ptr - specpdl; |
1194 Lisp_Object tem, cbuf; | 1200 Lisp_Object tem, cbuf; |
1195 | 1201 |
1196 cbuf = Fcurrent_buffer (); | 1202 cbuf = Fcurrent_buffer (); |
1207 | 1213 |
1208 /* This both uses start and checks its type. */ | 1214 /* This both uses start and checks its type. */ |
1209 Fgoto_char (start); | 1215 Fgoto_char (start); |
1210 Fnarrow_to_region (make_number (BEGV), end); | 1216 Fnarrow_to_region (make_number (BEGV), end); |
1211 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, | 1217 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, |
1212 !NILP (printflag), Qnil); | 1218 !NILP (printflag), Qnil, read_function); |
1213 | 1219 |
1214 return unbind_to (count, Qnil); | 1220 return unbind_to (count, Qnil); |
1215 } | 1221 } |
1216 | 1222 |
1217 #endif /* standalone */ | 1223 #endif /* standalone */ |