Commit 20edc1c9 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* lisp.h (modify_region): Rename to...

(modify_region_1): ...new prototype.
* textprop.c (modify_region): Now static.  Adjust users.
* insdel.c (modify_region): Rename to...
(modify_region_1): ...new function to work with current buffer.
Adjust comment and users.  Use true and false for boolean arg.
parent 62c2e5ed
2012-12-03 Dmitry Antipov <dmantipov@yandex.ru>
* lisp.h (modify_region): Rename to...
(modify_region_1): ...new prototype.
* textprop.c (modify_region): Now static. Adjust users.
* insdel.c (modify_region): Rename to...
(modify_region_1): ...new function to work with current buffer.
Adjust comment and users. Use true and false for booleans.
2012-12-03 Dmitry Antipov <dmantipov@yandex.ru>
 
* alloc.c (free_save_value): New function.
......
......@@ -213,7 +213,7 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e)
validate_region (&b, &e);
start = XFASTINT (b);
end = XFASTINT (e);
modify_region (current_buffer, start, end, 0);
modify_region_1 (start, end, false);
record_change (start, end - start);
start_byte = CHAR_TO_BYTE (start);
......
......@@ -2922,7 +2922,7 @@ Both characters must have the same length of multi-byte form. */)
else if (!changed)
{
changed = -1;
modify_region (current_buffer, pos, XINT (end), 0);
modify_region_1 (pos, XINT (end), false);
if (! NILP (noundo))
{
......@@ -3098,7 +3098,7 @@ It returns the number of characters changed. */)
pos = XINT (start);
pos_byte = CHAR_TO_BYTE (pos);
end_pos = XINT (end);
modify_region (current_buffer, pos, end_pos, 0);
modify_region_1 (pos, end_pos, false);
cnt = 0;
for (; pos < end_pos; )
......@@ -4622,7 +4622,7 @@ Transposing beyond buffer boundaries is an error. */)
if (end1 == start2) /* adjacent regions */
{
modify_region (current_buffer, start1, end2, 0);
modify_region_1 (start1, end2, false);
record_change (start1, len1 + len2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
......@@ -4681,8 +4681,8 @@ Transposing beyond buffer boundaries is an error. */)
{
USE_SAFE_ALLOCA;
modify_region (current_buffer, start1, end1, 0);
modify_region (current_buffer, start2, end2, 0);
modify_region_1 (start1, end1, false);
modify_region_1 (start2, end2, false);
record_change (start1, len1);
record_change (start2, len2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
......@@ -4715,7 +4715,7 @@ Transposing beyond buffer boundaries is an error. */)
{
USE_SAFE_ALLOCA;
modify_region (current_buffer, start1, end2, 0);
modify_region_1 (start1, end2, false);
record_change (start1, (end2 - start1));
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
......@@ -4748,7 +4748,7 @@ Transposing beyond buffer boundaries is an error. */)
USE_SAFE_ALLOCA;
record_change (start1, (end2 - start1));
modify_region (current_buffer, start1, end2, 0);
modify_region_1 (start1, end2, false);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
......
......@@ -1755,9 +1755,9 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
return deletion;
}
/* Call this if you're about to change the region of BUFFER from
character positions START to END. This checks the read-only
/* Call this if you're about to change the region of current buffer
from character positions 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.
......@@ -1766,16 +1766,11 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
Otherwise set CHARS_MODIFF to the new value of MODIFF. */
void
modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
bool preserve_chars_modiff)
modify_region_1 (ptrdiff_t start, ptrdiff_t end, bool preserve_chars_modiff)
{
struct buffer *old_buffer = current_buffer;
set_buffer_internal (buffer);
prepare_to_modify_buffer (start, end, NULL);
BUF_COMPUTE_UNCHANGED (buffer, start - 1, end);
BUF_COMPUTE_UNCHANGED (current_buffer, start - 1, end);
if (MODIFF <= SAVE_MODIFF)
record_first_change ();
......@@ -1783,11 +1778,9 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
if (! preserve_chars_modiff)
CHARS_MODIFF = MODIFF;
bset_point_before_scroll (buffer, Qnil);
set_buffer_internal (old_buffer);
bset_point_before_scroll (current_buffer, Qnil);
}
/* Check that it is okay to modify the buffer between START and END,
which are char positions.
......
......@@ -2796,7 +2796,7 @@ extern void del_range_byte (ptrdiff_t, ptrdiff_t, bool);
extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool);
extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, bool);
extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
extern void modify_region_1 (ptrdiff_t, ptrdiff_t, bool);
extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
......
......@@ -85,8 +85,18 @@ text_read_only (Lisp_Object propval)
xsignal0 (Qtext_read_only);
}
/* Prepare to modify the region of BUFFER from START to END. */
static void
modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
{
struct buffer *buf = XBUFFER (buffer), *old = current_buffer;
set_buffer_internal (buf);
modify_region_1 (XINT (start), XINT (end), true);
set_buffer_internal (old);
}
/* Extract the interval at the position pointed to by BEGIN from
OBJECT, a string or buffer. Additionally, check that the positions
pointed to by BEGIN and END are within the bounds of OBJECT, and
......@@ -1164,7 +1174,7 @@ Return t if any property value actually changed, nil otherwise. */)
}
if (BUFFERP (object))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
/* We are at the beginning of interval I, with LEN chars to scan. */
for (;;)
......@@ -1302,7 +1312,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
}
if (BUFFERP (object) && !NILP (coherent_change_p))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
set_text_properties_1 (start, end, properties, object, i);
......@@ -1451,7 +1461,7 @@ Use `set-text-properties' if you want to remove all text properties. */)
}
if (BUFFERP (object))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
/* We are at the beginning of an interval, with len to scan */
for (;;)
......@@ -1565,7 +1575,7 @@ Return t if any property was actually removed, nil otherwise. */)
else if (LENGTH (i) == len)
{
if (!modified && BUFFERP (object))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
......@@ -1578,7 +1588,7 @@ Return t if any property was actually removed, nil otherwise. */)
i = split_interval_left (i, len);
copy_properties (unchanged, i);
if (!modified && BUFFERP (object))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
......@@ -1589,7 +1599,7 @@ Return t if any property was actually removed, nil otherwise. */)
if (interval_has_some_properties_list (properties, i))
{
if (!modified && BUFFERP (object))
modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
modify_region (object, start, end);
remove_properties (Qnil, properties, i, object);
modified = 1;
}
......
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