aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-10 04:13:57 +0000
committerRichard M. Stallman1998-06-10 04:13:57 +0000
commit976350af4c4c1bd8142af4637f34d01a8b630680 (patch)
tree6b0b757c4658c69abce654eaed60293dcf4aefd9 /src
parent55607887e1a1a509d8030f04f1b6b9699fa469f6 (diff)
downloademacs-976350af4c4c1bd8142af4637f34d01a8b630680.tar.gz
emacs-976350af4c4c1bd8142af4637f34d01a8b630680.zip
(readevalloop): New arg READFUN. Callers changed.
(Feval_region): New arg READ_FUNCTION.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/lread.c b/src/lread.c
index fb49268d679..55001e75910 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -699,7 +699,7 @@ Return t if file exists.")
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. */
@@ -1021,16 +1021,17 @@ readevalloop_1 (old)
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
1026static void 1027static void
1027readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte) 1028readevalloop (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;
@@ -1083,10 +1084,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte)
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))
1087 val = read0 (readcharfun); 1088 val = call1 (readfun, readcharfun);
1088 else 1089 else if (! NILP (Vload_read_function))
1089 val = call1 (Vload_read_function, readcharfun); 1090 val = call1 (Vload_read_function, readcharfun);
1091 else
1092 val = read0 (readcharfun);
1090 } 1093 }
1091 1094
1092 val = (*evalfun) (val); 1095 val = (*evalfun) (val);
@@ -1143,7 +1146,7 @@ This function preserves the position of point.")
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;
@@ -1173,22 +1176,25 @@ point remains at the end of the last character read from the buffer.")
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
1181DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", 1184DEFUN ("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\
1183When called from programs, expects two arguments,\n\ 1186When called from programs, expects two arguments,\n\
1184giving starting and ending indices in the current buffer\n\ 1187giving starting and ending indices in the current buffer\n\
1185of the text to be executed.\n\ 1188of the text to be executed.\n\
1186Programs can pass third argument PRINTFLAG which controls output:\n\ 1189Programs can pass third argument PRINTFLAG which controls output:\n\
1187nil means discard it; anything else is stream for printing it.\n\ 1190nil means discard it; anything else is stream for printing it.\n\
1191Also the fourth argument READ-FUNCTION, if non-nil, is used\n\
1192instead of `read' to read each expression. It gets one argument\n\
1193which is the input stream for reading characters.\n\
1188\n\ 1194\n\
1189This function does not move point.") 1195This 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;
@@ -1209,7 +1215,7 @@ This function does not move point.")
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}