diff options
| author | Stefan Monnier | 2013-05-28 21:07:53 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-28 21:07:53 -0400 |
| commit | 22513e526eba97bd1014e4bacde0a8649fbe7870 (patch) | |
| tree | b03a93d706532036f6e38b57280879caeae0a07e /src/fileio.c | |
| parent | a5cf7779bc4a73c7c2f3174988e223c5cc783226 (diff) | |
| download | emacs-22513e526eba97bd1014e4bacde0a8649fbe7870.tar.gz emacs-22513e526eba97bd1014e4bacde0a8649fbe7870.zip | |
* src/fileio.c (Finsert_file_contents): Preserve undo info when reverting
a buffer.
Fixes: debbugs:8447
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 11 |
1 files changed, 9 insertions, 2 deletions
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. */) | |||
| 3506 | bool set_coding_system = 0; | 3506 | bool set_coding_system = 0; |
| 3507 | Lisp_Object coding_system; | 3507 | Lisp_Object coding_system; |
| 3508 | bool read_quit = 0; | 3508 | bool read_quit = 0; |
| 3509 | /* If the undo log only contains the insertion, there's no point | ||
| 3510 | keeping it. It's typically when we first fill a file-buffer. */ | ||
| 3511 | bool empty_undo_list_p | ||
| 3512 | = (!NILP (visit) && NILP (BVAR (current_buffer, undo_list)) | ||
| 3513 | && BEG == Z); | ||
| 3509 | Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; | 3514 | Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; |
| 3510 | bool we_locked_file = 0; | 3515 | bool we_locked_file = 0; |
| 3511 | bool deferred_remove_unwind_protect = 0; | 3516 | bool deferred_remove_unwind_protect = 0; |
| @@ -4108,6 +4113,7 @@ by calling `format-decode', which see. */) | |||
| 4108 | { | 4113 | { |
| 4109 | del_range_byte (same_at_start, same_at_end, 0); | 4114 | del_range_byte (same_at_start, same_at_end, 0); |
| 4110 | temp = GPT; | 4115 | temp = GPT; |
| 4116 | eassert (same_at_start == GPT_BYTE); | ||
| 4111 | same_at_start = GPT_BYTE; | 4117 | same_at_start = GPT_BYTE; |
| 4112 | } | 4118 | } |
| 4113 | else | 4119 | else |
| @@ -4120,6 +4126,7 @@ by calling `format-decode', which see. */) | |||
| 4120 | = buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | 4126 | = buf_bytepos_to_charpos (XBUFFER (conversion_buffer), |
| 4121 | same_at_start - BEGV_BYTE | 4127 | same_at_start - BEGV_BYTE |
| 4122 | + BUF_BEG_BYTE (XBUFFER (conversion_buffer))); | 4128 | + BUF_BEG_BYTE (XBUFFER (conversion_buffer))); |
| 4129 | eassert (same_at_start_charpos == temp - (BEGV - BEG)); | ||
| 4123 | inserted_chars | 4130 | inserted_chars |
| 4124 | = (buf_bytepos_to_charpos (XBUFFER (conversion_buffer), | 4131 | = (buf_bytepos_to_charpos (XBUFFER (conversion_buffer), |
| 4125 | same_at_start + inserted - BEGV_BYTE | 4132 | same_at_start + inserted - BEGV_BYTE |
| @@ -4404,7 +4411,7 @@ by calling `format-decode', which see. */) | |||
| 4404 | 4411 | ||
| 4405 | if (!NILP (visit)) | 4412 | if (!NILP (visit)) |
| 4406 | { | 4413 | { |
| 4407 | if (!EQ (BVAR (current_buffer, undo_list), Qt) && !nochange) | 4414 | if (empty_undo_list_p) |
| 4408 | bset_undo_list (current_buffer, Qnil); | 4415 | bset_undo_list (current_buffer, Qnil); |
| 4409 | 4416 | ||
| 4410 | if (NILP (handler)) | 4417 | if (NILP (handler)) |
| @@ -4546,7 +4553,7 @@ by calling `format-decode', which see. */) | |||
| 4546 | p = XCDR (p); | 4553 | p = XCDR (p); |
| 4547 | } | 4554 | } |
| 4548 | 4555 | ||
| 4549 | if (NILP (visit)) | 4556 | if (!empty_undo_list_p) |
| 4550 | { | 4557 | { |
| 4551 | bset_undo_list (current_buffer, old_undo); | 4558 | bset_undo_list (current_buffer, old_undo); |
| 4552 | if (CONSP (old_undo) && inserted != old_inserted) | 4559 | if (CONSP (old_undo) && inserted != old_inserted) |