aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1995-12-21 16:58:55 +0000
committerKarl Heuer1995-12-21 16:58:55 +0000
commit260e2e2a337a5f91ac889359992a1ab95dde8b78 (patch)
treec7a0daa73e3b126f12ee41614eba9709e9ddd187 /src
parent62380da21ca070a3bba2502909da5e0f873bb14a (diff)
downloademacs-260e2e2a337a5f91ac889359992a1ab95dde8b78.tar.gz
emacs-260e2e2a337a5f91ac889359992a1ab95dde8b78.zip
(Fset_time_zone_rule): Move static var environbuf
to top level. (syms_of_editfns): Initialize environbuf explicitly. (Vbuffer_access_fontified_property): New variable. (syms_of_editfns): Set up Lisp var. (make_buffer_string): Don't call the Vbuffer_access_fontify_functions if the text is already fontified. (Fbuffer_string): Pas 1 for PROPS arg. (update_buffer_properties): New subroutine. (Finsert_buffer_substring): Use update_buffer_properties. (make_buffer_string): New arg PROPS. (Fbuffer_string, Fbuffer_substring): Pass new arg. (Fbuffer_substring_no_properties): New function. (syms_of_editfns): defsubr it. (Vbuffer_access_fontify_functions): New variable. (Qbuffer_access_fontify_functions): New variable. (syms_of_editfns): Set up Lisp variable, initialize them. (make_buffer_string): Run this new hook.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c116
1 files changed, 105 insertions, 11 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 2ec1ac3cd42..ac0e140503a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -43,6 +43,11 @@ extern Lisp_Object make_time ();
43extern void insert_from_buffer (); 43extern void insert_from_buffer ();
44static long difftm (); 44static long difftm ();
45static void set_time_zone_rule (); 45static void set_time_zone_rule ();
46static void update_buffer_properties ();
47
48Lisp_Object Vbuffer_access_fontify_functions;
49Lisp_Object Qbuffer_access_fontify_functions;
50Lisp_Object Vbuffer_access_fontified_property;
46 51
47/* Some static data, and a function to initialize it for each run */ 52/* Some static data, and a function to initialize it for each run */
48 53
@@ -879,13 +884,17 @@ the data it can't find.")
879 return Fmake_list (2, Qnil); 884 return Fmake_list (2, Qnil);
880} 885}
881 886
887/* This holds the value of `environ' produced by the previous
888 call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule
889 has never been called. */
890static char **environbuf;
891
882DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, 892DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0,
883 "Set the local time zone using TZ, a string specifying a time zone rule.\n\ 893 "Set the local time zone using TZ, a string specifying a time zone rule.\n\
884If TZ is nil, use implementation-defined default time zone information.") 894If TZ is nil, use implementation-defined default time zone information.")
885 (tz) 895 (tz)
886 Lisp_Object tz; 896 Lisp_Object tz;
887{ 897{
888 static char **environbuf;
889 char *tzstring; 898 char *tzstring;
890 899
891 if (NILP (tz)) 900 if (NILP (tz))
@@ -1142,7 +1151,7 @@ from adjoining text, if those properties are sticky.")
1142/* Return a Lisp_String containing the text of the current buffer from 1151/* Return a Lisp_String containing the text of the current buffer from
1143 START to END. If text properties are in use and the current buffer 1152 START to END. If text properties are in use and the current buffer
1144 has properties in the range specified, the resulting string will also 1153 has properties in the range specified, the resulting string will also
1145 have them. 1154 have them, if PROPS is nonzero.
1146 1155
1147 We don't want to use plain old make_string here, because it calls 1156 We don't want to use plain old make_string here, because it calls
1148 make_uninit_string, which can cause the buffer arena to be 1157 make_uninit_string, which can cause the buffer arena to be
@@ -1153,8 +1162,9 @@ from adjoining text, if those properties are sticky.")
1153 buffer substrings. */ 1162 buffer substrings. */
1154 1163
1155Lisp_Object 1164Lisp_Object
1156make_buffer_string (start, end) 1165make_buffer_string (start, end, props)
1157 int start, end; 1166 int start, end;
1167 int props;
1158{ 1168{
1159 Lisp_Object result, tem, tem1; 1169 Lisp_Object result, tem, tem1;
1160 1170
@@ -1164,17 +1174,58 @@ make_buffer_string (start, end)
1164 result = make_uninit_string (end - start); 1174 result = make_uninit_string (end - start);
1165 bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start); 1175 bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start);
1166 1176
1167 tem = Fnext_property_change (make_number (start), Qnil, make_number (end)); 1177 /* If desired, update and copy the text properties. */
1168 tem1 = Ftext_properties_at (make_number (start), Qnil);
1169
1170#ifdef USE_TEXT_PROPERTIES 1178#ifdef USE_TEXT_PROPERTIES
1171 if (XINT (tem) != end || !NILP (tem1)) 1179 if (props)
1172 copy_intervals_to_string (result, current_buffer, start, end - start); 1180 {
1181 update_buffer_properties (start, end);
1182
1183 tem = Fnext_property_change (make_number (start), Qnil, make_number (end));
1184 tem1 = Ftext_properties_at (make_number (start), Qnil);
1185
1186 if (XINT (tem) != end || !NILP (tem1))
1187 copy_intervals_to_string (result, current_buffer, start, end - start);
1188 }
1173#endif 1189#endif
1174 1190
1175 return result; 1191 return result;
1176} 1192}
1177 1193
1194/* Call Vbuffer_access_fontify_functions for the range START ... END
1195 in the current buffer, if necessary. */
1196
1197static void
1198update_buffer_properties (start, end)
1199 int start, end;
1200{
1201#ifdef USE_TEXT_PROPERTIES
1202 /* If this buffer has some access functions,
1203 call them, specifying the range of the buffer being accessed. */
1204 if (!NILP (Vbuffer_access_fontify_functions))
1205 {
1206 Lisp_Object args[3];
1207 Lisp_Object tem;
1208
1209 args[0] = Qbuffer_access_fontify_functions;
1210 XSETINT (args[1], start);
1211 XSETINT (args[2], end);
1212
1213 /* But don't call them if we can tell that the work
1214 has already been done. */
1215 if (!NILP (Vbuffer_access_fontified_property))
1216 {
1217 tem = Ftext_property_any (args[1], args[2],
1218 Vbuffer_access_fontified_property,
1219 Qnil, Qnil);
1220 if (! NILP (tem))
1221 Frun_hook_with_args (3, &args);
1222 }
1223 else
1224 Frun_hook_with_args (3, &args);
1225 }
1226#endif
1227}
1228
1178DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0, 1229DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0,
1179 "Return the contents of part of the current buffer as a string.\n\ 1230 "Return the contents of part of the current buffer as a string.\n\
1180The two arguments START and END are character positions;\n\ 1231The two arguments START and END are character positions;\n\
@@ -1188,7 +1239,24 @@ they can be in either order.")
1188 beg = XINT (b); 1239 beg = XINT (b);
1189 end = XINT (e); 1240 end = XINT (e);
1190 1241
1191 return make_buffer_string (beg, end); 1242 return make_buffer_string (beg, end, 1);
1243}
1244
1245DEFUN ("buffer-substring-no-properties", Fbuffer_substring_no_properties,
1246 Sbuffer_substring_no_properties, 2, 2, 0,
1247 "Return the characters of part of the buffer, without the text properties.\n\
1248The two arguments START and END are character positions;\n\
1249they can be in either order.")
1250 (b, e)
1251 Lisp_Object b, e;
1252{
1253 register int beg, end;
1254
1255 validate_region (&b, &e);
1256 beg = XINT (b);
1257 end = XINT (e);
1258
1259 return make_buffer_string (beg, end, 0);
1192} 1260}
1193 1261
1194DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0, 1262DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0,
@@ -1197,7 +1265,7 @@ If narrowing is in effect, this function returns only the visible part\n\
1197of the buffer.") 1265of the buffer.")
1198 () 1266 ()
1199{ 1267{
1200 return make_buffer_string (BEGV, ZV); 1268 return make_buffer_string (BEGV, ZV, 1);
1201} 1269}
1202 1270
1203DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, 1271DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
@@ -1210,7 +1278,7 @@ They default to the beginning and the end of BUFFER.")
1210 Lisp_Object buf, b, e; 1278 Lisp_Object buf, b, e;
1211{ 1279{
1212 register int beg, end, temp; 1280 register int beg, end, temp;
1213 register struct buffer *bp; 1281 register struct buffer *bp, *obuf;
1214 Lisp_Object buffer; 1282 Lisp_Object buffer;
1215 1283
1216 buffer = Fget_buffer (buf); 1284 buffer = Fget_buffer (buf);
@@ -1239,6 +1307,11 @@ They default to the beginning and the end of BUFFER.")
1239 if (!(BUF_BEGV (bp) <= beg && end <= BUF_ZV (bp))) 1307 if (!(BUF_BEGV (bp) <= beg && end <= BUF_ZV (bp)))
1240 args_out_of_range (b, e); 1308 args_out_of_range (b, e);
1241 1309
1310 obuf = current_buffer;
1311 set_buffer_internal_1 (bp);
1312 update_buffer_properties (beg, end);
1313 set_buffer_internal_1 (obuf);
1314
1242 insert_from_buffer (bp, beg, end - beg, 0); 1315 insert_from_buffer (bp, beg, end - beg, 0);
1243 return Qnil; 1316 return Qnil;
1244} 1317}
@@ -2305,6 +2378,26 @@ Transposing beyond buffer boundaries is an error.")
2305void 2378void
2306syms_of_editfns () 2379syms_of_editfns ()
2307{ 2380{
2381 environbuf = 0;
2382
2383 Qbuffer_access_fontify_functions
2384 = intern ("buffer-access-fontify-functions");
2385 staticpro (&Qbuffer_access_fontify_functions);
2386
2387 DEFVAR_LISP ("buffer-access-fontify-functions",
2388 &Vbuffer_access_fontify_functions,
2389 "List of functions called by `buffer-substring' to fontify if necessary.\n\
2390Each function is called with two arguments which specify the range\n\
2391of the buffer being accessed.");
2392 Vbuffer_access_fontify_functions = Qnil;
2393
2394 DEFVAR_LISP ("buffer_access_fontified_property",
2395 &Vbuffer_access_fontified_property,
2396 "Property which (if non-nil) indicates text has been fontified.\n\
2397`buffer-substring' need not call the `buffer-access-fontify-functions'\n\
2398functions if all the text being accessed has this property.");
2399 Vbuffer_access_fontified_property = Qnil;
2400
2308 DEFVAR_LISP ("system-name", &Vsystem_name, 2401 DEFVAR_LISP ("system-name", &Vsystem_name,
2309 "The name of the machine Emacs is running on."); 2402 "The name of the machine Emacs is running on.");
2310 2403
@@ -2322,6 +2415,7 @@ syms_of_editfns ()
2322 defsubr (&Sstring_to_char); 2415 defsubr (&Sstring_to_char);
2323 defsubr (&Schar_to_string); 2416 defsubr (&Schar_to_string);
2324 defsubr (&Sbuffer_substring); 2417 defsubr (&Sbuffer_substring);
2418 defsubr (&Sbuffer_substring_no_properties);
2325 defsubr (&Sbuffer_string); 2419 defsubr (&Sbuffer_string);
2326 2420
2327 defsubr (&Spoint_marker); 2421 defsubr (&Spoint_marker);