summaryrefslogtreecommitdiff
path: root/src/insdel.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2013-08-06 09:30:18 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2013-08-06 09:30:18 +0400
commit00012b86257f33dd4e08e79b814f4a7ad6010713 (patch)
tree1f01b7ccab453278d5e697ae2bf3dd34cd119a48 /src/insdel.c
parent307764cc3a2afd363cae0a36a6d18dfa68788cb4 (diff)
Invalidate region caches only if buffer text is going to be changed.
* lisp.h (modify_region_1): Remove 3rd arg and rename to... (modify_text): ...new prototype. (prepare_to_modify_buffer_1): New prototype. * textprop.c (modify_region): Rename to... (modify_text_properties): ...new function. (add_text_properties_1, set_text_properties, Fremove_text_properties) (Fremove_list_of_text_properties): Adjust users. * insdel.c (modify_region_1): Remove 3rd arg and reimplement as... (modify_text): ...new function. (prepare_to_modify_buffer): Reimplement mostly as a wrapper for... (prepare_to_modify_buffer_1): ...new function. * casefiddle.c (casify_region): * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal) (Ftranspose_regions): Use modify_text.
Diffstat (limited to 'src/insdel.c')
-rw-r--r--src/insdel.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 58c3e15c23..ac64299a99 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1756,27 +1756,22 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
return deletion;
}
-/* Call this if you're about to change the region of current buffer
+/* Call this if you're about to change the text 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.
-
- If PRESERVE_CHARS_MODIFF, do not update CHARS_MODIFF.
- Otherwise set CHARS_MODIFF to the new value of MODIFF. */
+ area. */
void
-modify_region_1 (ptrdiff_t start, ptrdiff_t end, bool preserve_chars_modiff)
+modify_text (ptrdiff_t start, ptrdiff_t end)
{
prepare_to_modify_buffer (start, end, NULL);
BUF_COMPUTE_UNCHANGED (current_buffer, start - 1, end);
-
if (MODIFF <= SAVE_MODIFF)
record_first_change ();
MODIFF++;
- if (! preserve_chars_modiff)
- CHARS_MODIFF = MODIFF;
+ CHARS_MODIFF = MODIFF;
bset_point_before_scroll (current_buffer, Qnil);
}
@@ -1792,8 +1787,8 @@ modify_region_1 (ptrdiff_t start, ptrdiff_t end, bool preserve_chars_modiff)
by holding its value temporarily in a marker. */
void
-prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
- ptrdiff_t *preserve_ptr)
+prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t *preserve_ptr)
{
struct buffer *base_buffer;
@@ -1864,6 +1859,17 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
}
signal_before_change (start, end, preserve_ptr);
+ Vdeactivate_mark = Qt;
+}
+
+/* Like above, but called when we know that the buffer text
+ will be modified and region caches should be invalidated. */
+
+void
+prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t *preserve_ptr)
+{
+ prepare_to_modify_buffer_1 (start, end, preserve_ptr);
if (current_buffer->newline_cache)
invalidate_region_cache (current_buffer,
@@ -1873,10 +1879,8 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
invalidate_region_cache (current_buffer,
current_buffer->width_run_cache,
start - BEG, Z - end);
-
- Vdeactivate_mark = Qt;
}
-
+
/* These macros work with an argument named `preserve_ptr'
and a local variable named `preserve_marker'. */