if (! giveup_match_end)
{
ptrdiff_t temp;
+ ptrdiff_t this_count = SPECPDL_INDEX ();
/* We win! We can handle REPLACE the optimized way. */
beg_offset += same_at_start - BEGV_BYTE;
end_offset -= ZV_BYTE - same_at_end;
- invalidate_buffer_caches (current_buffer,
- BYTE_TO_CHAR (same_at_start),
- same_at_end_charpos);
- del_range_byte (same_at_start, same_at_end, 0);
+ /* This binding is to avoid ask-user-about-supersession-threat
+ being called in insert_from_buffer or del_range_bytes (via
+ prepare_to_modify_buffer).
+ AFAICT we could avoid ask-user-about-supersession-threat by setting
+ current_buffer->modtime earlier, but we could still end up calling
+ ask-user-about-supersession-threat if the file is modified while
+ we read it, so we bind buffer-file-name instead. */
+ specbind (intern ("buffer-file-name"), Qnil);
+ del_range_byte (same_at_start, same_at_end);
/* Insert from the file at the proper position. */
temp = BYTE_TO_CHAR (same_at_start);
SET_PT_BOTH (temp, same_at_start);
+ unbind_to (this_count, Qnil);
/* If display currently starts at beginning of line,
keep it that way. */
/* Truncate the buffer to the size of the file. */
if (same_at_start != same_at_end)
{
- invalidate_buffer_caches (current_buffer,
- BYTE_TO_CHAR (same_at_start),
- BYTE_TO_CHAR (same_at_end));
- del_range_byte (same_at_start, same_at_end, 0);
+ /* See previous specbind for the reason behind this. */
+ specbind (intern ("buffer-file-name"), Qnil);
+ del_range_byte (same_at_start, same_at_end);
}
inserted = 0;
we are taking from the decoded string. */
inserted -= (ZV_BYTE - same_at_end) + (same_at_start - BEGV_BYTE);
+ /* See previous specbind for the reason behind this. */
+ specbind (intern ("buffer-file-name"), Qnil);
if (same_at_end != same_at_start)
{
- invalidate_buffer_caches (current_buffer,
- BYTE_TO_CHAR (same_at_start),
- same_at_end_charpos);
- del_range_byte (same_at_start, same_at_end, 0);
+ del_range_byte (same_at_start, same_at_end);
temp = GPT;
eassert (same_at_start == GPT_BYTE);
same_at_start = GPT_BYTE;
same_at_start + inserted - BEGV_BYTE
+ BUF_BEG_BYTE (XBUFFER (conversion_buffer)))
- same_at_start_charpos);
- /* This binding is to avoid ask-user-about-supersession-threat
- being called in insert_from_buffer (via in
- prepare_to_modify_buffer). */
- specbind (intern ("buffer-file-name"), Qnil);
insert_from_buffer (XBUFFER (conversion_buffer),
same_at_start_charpos, inserted_chars, 0);
/* Set `inserted' to the number of inserted characters. */
/* Like del_range_1 but args are byte positions, not char positions. */
void
-del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, bool prepare)
+del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte)
{
ptrdiff_t from, to;
from = BYTE_TO_CHAR (from_byte);
to = BYTE_TO_CHAR (to_byte);
- if (prepare)
- {
- ptrdiff_t old_from = from, old_to = Z - to;
- ptrdiff_t range_length = to - from;
- prepare_to_modify_buffer (from, to, &from);
- to = from + range_length;
-
- if (old_from != from)
- from_byte = CHAR_TO_BYTE (from);
- if (to > ZV)
- {
- to = ZV;
- to_byte = ZV_BYTE;
- }
- else if (old_to == Z - to)
- to_byte = CHAR_TO_BYTE (to);
- }
+ {
+ ptrdiff_t old_from = from, old_to = Z - to;
+ ptrdiff_t range_length = to - from;
+ prepare_to_modify_buffer (from, to, &from);
+ to = from + range_length;
+
+ if (old_from != from)
+ from_byte = CHAR_TO_BYTE (from);
+ if (to > ZV)
+ {
+ to = ZV;
+ to_byte = ZV_BYTE;
+ }
+ else if (old_to == Z - to)
+ to_byte = CHAR_TO_BYTE (to);
+ }
del_range_2 (from, from_byte, to, to_byte, 0);
signal_after_change (from, to - from, 0);
ptrdiff_t, bool);
extern void del_range (ptrdiff_t, ptrdiff_t);
extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, bool, bool);
-extern void del_range_byte (ptrdiff_t, ptrdiff_t, bool);
+extern void del_range_byte (ptrdiff_t, ptrdiff_t);
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);