* src/fileio.c (Finsert_file_contents): Preserve undo info when reverting

a buffer.

Fixes: debbugs:8447
This commit is contained in:
Stefan Monnier 2013-05-28 21:07:53 -04:00
parent a5cf7779bc
commit 22513e526e
2 changed files with 16 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2013-05-29 Stefan Monnier <monnier@iro.umontreal.ca>
* fileio.c (Finsert_file_contents): Preserve undo info when reverting
a buffer (bug#8447).
2013-05-27 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (pos_visible_p): When CHARPOS is displayed frrom a
@ -25,8 +30,8 @@
(struct MonitorInfo): New struct.
(free_monitors, make_monitor_attribute_list): Declare.
* frame.c (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): New
Lisp_Object:s.
* frame.c (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource):
New Lisp_Object:s.
(free_monitors, make_monitor_attribute_list): New functions.
(syms_of_frame): DEFSYM Qgeometry, Qworkarea, Qmm_size, Qframes,
Qsource.

View file

@ -3506,6 +3506,11 @@ by calling `format-decode', which see. */)
bool set_coding_system = 0;
Lisp_Object coding_system;
bool read_quit = 0;
/* If the undo log only contains the insertion, there's no point
keeping it. It's typically when we first fill a file-buffer. */
bool empty_undo_list_p
= (!NILP (visit) && NILP (BVAR (current_buffer, undo_list))
&& BEG == Z);
Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
bool we_locked_file = 0;
bool deferred_remove_unwind_protect = 0;
@ -4108,6 +4113,7 @@ by calling `format-decode', which see. */)
{
del_range_byte (same_at_start, same_at_end, 0);
temp = GPT;
eassert (same_at_start == GPT_BYTE);
same_at_start = GPT_BYTE;
}
else
@ -4120,6 +4126,7 @@ by calling `format-decode', which see. */)
= buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
same_at_start - BEGV_BYTE
+ BUF_BEG_BYTE (XBUFFER (conversion_buffer)));
eassert (same_at_start_charpos == temp - (BEGV - BEG));
inserted_chars
= (buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
same_at_start + inserted - BEGV_BYTE
@ -4404,7 +4411,7 @@ by calling `format-decode', which see. */)
if (!NILP (visit))
{
if (!EQ (BVAR (current_buffer, undo_list), Qt) && !nochange)
if (empty_undo_list_p)
bset_undo_list (current_buffer, Qnil);
if (NILP (handler))
@ -4546,7 +4553,7 @@ by calling `format-decode', which see. */)
p = XCDR (p);
}
if (NILP (visit))
if (!empty_undo_list_p)
{
bset_undo_list (current_buffer, old_undo);
if (CONSP (old_undo) && inserted != old_inserted)