aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-05-14 14:43:30 +0000
committerJim Blandy1993-05-14 14:43:30 +0000
commit04a759c81b944287c3a826eed57ee56a3bea5c03 (patch)
tree02784ac68d6821607065eb037f3e97dadc8ec13b /src
parent6c523803b30c3d41a21ce36fbfb0437bf6ce68e5 (diff)
downloademacs-04a759c81b944287c3a826eed57ee56a3bea5c03.tar.gz
emacs-04a759c81b944287c3a826eed57ee56a3bea5c03.zip
The text property routines can now modify buffers other
than the current one. * insdel.c (modify_region): New argument BUFFER. Select that buffer while we prepare for the modification, and switch back when we're done. * textprop.c (add_properties, remove_properties): Pass the buffer being modified as the first argument to modify_region. * editfns.c (Fsubst_char_in_region, Ftranslate_region): Pass the current_buffer as the first argument to modify_region. * casefiddle.c (casify_region): Same.
Diffstat (limited to 'src')
-rw-r--r--src/casefiddle.c4
-rw-r--r--src/editfns.c4
-rw-r--r--src/insdel.c15
-rw-r--r--src/textprop.c12
4 files changed, 26 insertions, 9 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c
index d496ffdf6dd..ca5127d5480 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -117,8 +117,8 @@ casify_region (flag, b, e)
117 return; 117 return;
118 118
119 validate_region (&b, &e); 119 validate_region (&b, &e);
120 modify_region (XFASTINT (b), XFASTINT (e)); 120 modify_region (current_buffer, XFASTINT (b), XFASTINT (e));
121 record_change (XFASTINT (b), XFASTINT (e) - XFASTINT (b)); 121 record_change (current_buffer, XFASTINT (b), XFASTINT (e) - XFASTINT (b));
122 122
123 for (i = XFASTINT (b); i < XFASTINT (e); i++) 123 for (i = XFASTINT (b); i < XFASTINT (e); i++)
124 { 124 {
diff --git a/src/editfns.c b/src/editfns.c
index 7b3db6203d3..86d292f2976 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1001,7 +1001,7 @@ and don't mark the buffer as really changed.")
1001 stop = XINT (end); 1001 stop = XINT (end);
1002 look = XINT (fromchar); 1002 look = XINT (fromchar);
1003 1003
1004 modify_region (pos, stop); 1004 modify_region (current_buffer, pos, stop);
1005 if (! NILP (noundo)) 1005 if (! NILP (noundo))
1006 { 1006 {
1007 if (MODIFF - 1 == current_buffer->save_modified) 1007 if (MODIFF - 1 == current_buffer->save_modified)
@@ -1051,7 +1051,7 @@ for the character with code N. Returns the number of characters changed.")
1051 1051
1052 pos = XINT (start); 1052 pos = XINT (start);
1053 stop = XINT (end); 1053 stop = XINT (end);
1054 modify_region (pos, stop); 1054 modify_region (current_buffer, pos, stop);
1055 1055
1056 cnt = 0; 1056 cnt = 0;
1057 for (; pos < stop; ++pos) 1057 for (; pos < stop; ++pos)
diff --git a/src/insdel.c b/src/insdel.c
index a1b3b1ff113..9d2572bfe62 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -473,9 +473,19 @@ del_range (from, to)
473 signal_after_change (from, numdel, 0); 473 signal_after_change (from, numdel, 0);
474} 474}
475 475
476modify_region (start, end) 476/* Call this if you're about to change the region of BUFFER from START
477 to END. This checks the read-only properties of the region, calls
478 the necessary modification hooks, and warns the next redisplay that
479 it should pay attention to that area. */
480modify_region (buffer, start, end)
481 struct buffer *buffer;
477 int start, end; 482 int start, end;
478{ 483{
484 struct buffer *old_buffer = current_buffer;
485
486 if (buffer != old_buffer)
487 set_buffer_internal (buffer);
488
479 prepare_to_modify_buffer (start, end); 489 prepare_to_modify_buffer (start, end);
480 490
481 if (start - 1 < beg_unchanged || unchanged_modified == MODIFF) 491 if (start - 1 < beg_unchanged || unchanged_modified == MODIFF)
@@ -484,6 +494,9 @@ modify_region (start, end)
484 || unchanged_modified == MODIFF) 494 || unchanged_modified == MODIFF)
485 end_unchanged = Z - end; 495 end_unchanged = Z - end;
486 MODIFF++; 496 MODIFF++;
497
498 if (buffer != old_buffer)
499 set_buffer_internal (old_buffer);
487} 500}
488 501
489/* Check that it is okay to modify the buffer between START and END. 502/* Check that it is okay to modify the buffer between START and END.
diff --git a/src/textprop.c b/src/textprop.c
index db618c7e4c7..e651cbf243b 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -312,7 +312,8 @@ add_properties (plist, i, object)
312 { 312 {
313 record_property_change (i->position, LENGTH (i), 313 record_property_change (i->position, LENGTH (i),
314 sym1, Fcar (this_cdr), object); 314 sym1, Fcar (this_cdr), object);
315 modify_region (make_number (i->position), 315 modify_region (XBUFFER (object),
316 make_number (i->position),
316 make_number (i->position + LENGTH (i))); 317 make_number (i->position + LENGTH (i)));
317 } 318 }
318 319
@@ -329,7 +330,8 @@ add_properties (plist, i, object)
329 { 330 {
330 record_property_change (i->position, LENGTH (i), 331 record_property_change (i->position, LENGTH (i),
331 sym1, Qnil, object); 332 sym1, Qnil, object);
332 modify_region (make_number (i->position), 333 modify_region (XBUFFER (object),
334 make_number (i->position),
333 make_number (i->position + LENGTH (i))); 335 make_number (i->position + LENGTH (i)));
334 } 336 }
335 i->plist = Fcons (sym1, Fcons (val1, i->plist)); 337 i->plist = Fcons (sym1, Fcons (val1, i->plist));
@@ -367,7 +369,8 @@ remove_properties (plist, i, object)
367 record_property_change (i->position, LENGTH (i), 369 record_property_change (i->position, LENGTH (i),
368 sym, Fcar (Fcdr (current_plist)), 370 sym, Fcar (Fcdr (current_plist)),
369 object); 371 object);
370 modify_region (make_number (i->position), 372 modify_region (XBUFFER (object),
373 make_number (i->position),
371 make_number (i->position + LENGTH (i))); 374 make_number (i->position + LENGTH (i)));
372 } 375 }
373 376
@@ -386,7 +389,8 @@ remove_properties (plist, i, object)
386 { 389 {
387 record_property_change (i->position, LENGTH (i), 390 record_property_change (i->position, LENGTH (i),
388 sym, Fcar (Fcdr (this)), object); 391 sym, Fcar (Fcdr (this)), object);
389 modify_region (make_number (i->position), 392 modify_region (XBUFFER (object),
393 make_number (i->position),
390 make_number (i->position + LENGTH (i))); 394 make_number (i->position + LENGTH (i)));
391 } 395 }
392 396