From: Stefan Monnier Date: Wed, 29 May 2013 01:07:53 +0000 (-0400) Subject: * src/fileio.c (Finsert_file_contents): Preserve undo info when reverting X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~151 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=22513e526eba97bd1014e4bacde0a8649fbe7870;p=emacs.git * src/fileio.c (Finsert_file_contents): Preserve undo info when reverting a buffer. Fixes: debbugs:8447 --- diff --git a/src/ChangeLog b/src/ChangeLog index b1f13e62b40..4b1281c17e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-05-29 Stefan Monnier + + * fileio.c (Finsert_file_contents): Preserve undo info when reverting + a buffer (bug#8447). + 2013-05-27 Eli Zaretskii * 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. diff --git a/src/fileio.c b/src/fileio.c index f20721251e6..e2b1007fb0b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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)