Commit 04a759c8 authored by Jim Blandy's avatar Jim Blandy
Browse files

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.
parent 6c523803
...@@ -117,8 +117,8 @@ casify_region (flag, b, e) ...@@ -117,8 +117,8 @@ casify_region (flag, b, e)
return; return;
validate_region (&b, &e); validate_region (&b, &e);
modify_region (XFASTINT (b), XFASTINT (e)); modify_region (current_buffer, XFASTINT (b), XFASTINT (e));
record_change (XFASTINT (b), XFASTINT (e) - XFASTINT (b)); record_change (current_buffer, XFASTINT (b), XFASTINT (e) - XFASTINT (b));
for (i = XFASTINT (b); i < XFASTINT (e); i++) for (i = XFASTINT (b); i < XFASTINT (e); i++)
{ {
......
...@@ -1001,7 +1001,7 @@ and don't mark the buffer as really changed.") ...@@ -1001,7 +1001,7 @@ and don't mark the buffer as really changed.")
stop = XINT (end); stop = XINT (end);
look = XINT (fromchar); look = XINT (fromchar);
modify_region (pos, stop); modify_region (current_buffer, pos, stop);
if (! NILP (noundo)) if (! NILP (noundo))
{ {
if (MODIFF - 1 == current_buffer->save_modified) if (MODIFF - 1 == current_buffer->save_modified)
...@@ -1051,7 +1051,7 @@ for the character with code N. Returns the number of characters changed.") ...@@ -1051,7 +1051,7 @@ for the character with code N. Returns the number of characters changed.")
pos = XINT (start); pos = XINT (start);
stop = XINT (end); stop = XINT (end);
modify_region (pos, stop); modify_region (current_buffer, pos, stop);
cnt = 0; cnt = 0;
for (; pos < stop; ++pos) for (; pos < stop; ++pos)
......
...@@ -473,9 +473,19 @@ del_range (from, to) ...@@ -473,9 +473,19 @@ del_range (from, to)
signal_after_change (from, numdel, 0); 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; int start, end;
{ {
struct buffer *old_buffer = current_buffer;
if (buffer != old_buffer)
set_buffer_internal (buffer);
prepare_to_modify_buffer (start, end); prepare_to_modify_buffer (start, end);
if (start - 1 < beg_unchanged || unchanged_modified == MODIFF) if (start - 1 < beg_unchanged || unchanged_modified == MODIFF)
...@@ -484,6 +494,9 @@ modify_region (start, end) ...@@ -484,6 +494,9 @@ modify_region (start, end)
|| unchanged_modified == MODIFF) || unchanged_modified == MODIFF)
end_unchanged = Z - end; end_unchanged = Z - end;
MODIFF++; MODIFF++;
if (buffer != old_buffer)
set_buffer_internal (old_buffer);
} }
/* Check that it is okay to modify the buffer between START and END. /* Check that it is okay to modify the buffer between START and END.
......
...@@ -312,7 +312,8 @@ add_properties (plist, i, object) ...@@ -312,7 +312,8 @@ add_properties (plist, i, object)
{ {
record_property_change (i->position, LENGTH (i), record_property_change (i->position, LENGTH (i),
sym1, Fcar (this_cdr), object); 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))); make_number (i->position + LENGTH (i)));
} }
...@@ -329,7 +330,8 @@ add_properties (plist, i, object) ...@@ -329,7 +330,8 @@ add_properties (plist, i, object)
{ {
record_property_change (i->position, LENGTH (i), record_property_change (i->position, LENGTH (i),
sym1, Qnil, object); sym1, Qnil, object);
modify_region (make_number (i->position), modify_region (XBUFFER (object),
make_number (i->position),
make_number (i->position + LENGTH (i))); make_number (i->position + LENGTH (i)));
} }
i->plist = Fcons (sym1, Fcons (val1, i->plist)); i->plist = Fcons (sym1, Fcons (val1, i->plist));
...@@ -367,7 +369,8 @@ remove_properties (plist, i, object) ...@@ -367,7 +369,8 @@ remove_properties (plist, i, object)
record_property_change (i->position, LENGTH (i), record_property_change (i->position, LENGTH (i),
sym, Fcar (Fcdr (current_plist)), sym, Fcar (Fcdr (current_plist)),
object); object);
modify_region (make_number (i->position), modify_region (XBUFFER (object),
make_number (i->position),
make_number (i->position + LENGTH (i))); make_number (i->position + LENGTH (i)));
} }
...@@ -386,7 +389,8 @@ remove_properties (plist, i, object) ...@@ -386,7 +389,8 @@ remove_properties (plist, i, object)
{ {
record_property_change (i->position, LENGTH (i), record_property_change (i->position, LENGTH (i),
sym, Fcar (Fcdr (this)), object); 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))); make_number (i->position + LENGTH (i)));
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment