changeset 2783:789c11177579

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.
author Jim Blandy <jimb@redhat.com>
date Fri, 14 May 1993 14:43:30 +0000
parents 683f4472f1c8
children f8c6796b7777
files src/casefiddle.c src/editfns.c src/insdel.c src/textprop.c
diffstat 4 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/casefiddle.c	Fri May 14 14:43:00 1993 +0000
+++ b/src/casefiddle.c	Fri May 14 14:43:30 1993 +0000
@@ -117,8 +117,8 @@
     return;
 
   validate_region (&b, &e);
-  modify_region (XFASTINT (b), XFASTINT (e));
-  record_change (XFASTINT (b), XFASTINT (e) - XFASTINT (b));
+  modify_region (current_buffer, XFASTINT (b), XFASTINT (e));
+  record_change (current_buffer, XFASTINT (b), XFASTINT (e) - XFASTINT (b));
 
   for (i = XFASTINT (b); i < XFASTINT (e); i++)
     {
--- a/src/editfns.c	Fri May 14 14:43:00 1993 +0000
+++ b/src/editfns.c	Fri May 14 14:43:30 1993 +0000
@@ -1001,7 +1001,7 @@
   stop = XINT (end);
   look = XINT (fromchar);
 
-  modify_region (pos, stop);
+  modify_region (current_buffer, pos, stop);
   if (! NILP (noundo))
     {
       if (MODIFF - 1 == current_buffer->save_modified)
@@ -1051,7 +1051,7 @@
 
   pos = XINT (start);
   stop = XINT (end);
-  modify_region (pos, stop);
+  modify_region (current_buffer, pos, stop);
 
   cnt = 0;
   for (; pos < stop; ++pos)
--- a/src/insdel.c	Fri May 14 14:43:00 1993 +0000
+++ b/src/insdel.c	Fri May 14 14:43:30 1993 +0000
@@ -473,9 +473,19 @@
   signal_after_change (from, numdel, 0);
 }
 
-modify_region (start, end)
+/* Call this if you're about to change the region of BUFFER from START
+   to END.  This checks the read-only properties of the region, calls
+   the necessary modification hooks, and warns the next redisplay that
+   it should pay attention to that area.  */
+modify_region (buffer, start, end)
+     struct buffer *buffer;
      int start, end;
 {
+  struct buffer *old_buffer = current_buffer;
+
+  if (buffer != old_buffer)
+    set_buffer_internal (buffer);
+
   prepare_to_modify_buffer (start, end);
 
   if (start - 1 < beg_unchanged || unchanged_modified == MODIFF)
@@ -484,6 +494,9 @@
       || unchanged_modified == MODIFF)
     end_unchanged = Z - end;
   MODIFF++;
+
+  if (buffer != old_buffer)
+    set_buffer_internal (old_buffer);
 }
 
 /* Check that it is okay to modify the buffer between START and END.
--- a/src/textprop.c	Fri May 14 14:43:00 1993 +0000
+++ b/src/textprop.c	Fri May 14 14:43:30 1993 +0000
@@ -312,7 +312,8 @@
 	      {
 		record_property_change (i->position, LENGTH (i),
 					sym1, Fcar (this_cdr), object);
-		modify_region (make_number (i->position),
+		modify_region (XBUFFER (object),
+			       make_number (i->position),
 			       make_number (i->position + LENGTH (i)));
 	      }
 
@@ -329,7 +330,8 @@
 	    {
 	      record_property_change (i->position, LENGTH (i),
 				      sym1, Qnil, object);
-	      modify_region (make_number (i->position),
+	      modify_region (XBUFFER (object),
+			     make_number (i->position),
 			     make_number (i->position + LENGTH (i)));
 	    }
 	  i->plist = Fcons (sym1, Fcons (val1, i->plist));
@@ -367,7 +369,8 @@
 	      record_property_change (i->position, LENGTH (i),
 				      sym, Fcar (Fcdr (current_plist)),
 				      object);
-	      modify_region (make_number (i->position),
+	      modify_region (XBUFFER (object),
+			     make_number (i->position),
 			     make_number (i->position + LENGTH (i)));
 	    }
 
@@ -386,7 +389,8 @@
 		{
 		  record_property_change (i->position, LENGTH (i),
 					  sym, Fcar (Fcdr (this)), object);
-		  modify_region (make_number (i->position),
+		  modify_region (XBUFFER (object),
+				 make_number (i->position),
 				 make_number (i->position + LENGTH (i)));
 		}