[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: undo weirdness with insert-file-contents
From: |
martin rudalics |
Subject: |
Re: undo weirdness with insert-file-contents |
Date: |
Fri, 29 Feb 2008 23:42:25 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
This is trickier than I thought. The primary reason of the bug is that
record_insert combines two adjacent insertions thus messing up my
comparison after format decoding wrt the start of the inserted region.
Unless someone has a better idea, I'd handle this by inserting an undo
boundary for `insert-file-contents'. The second problem is that
`insert-file-contents' does not consider an insertion a buffer change
when the buffer is empty. This is obviously TRT in the file-visiting
case, but doesn't seem quite right in the non-visiting case. Both
issues are involved in the buggy behaviors observed. Please try another
time with the attached patch (I'm afraid it won't be the last).
*** fileio.c.~1.602.~ Thu Feb 14 20:41:44 2008
--- fileio.c Fri Feb 29 23:30:18 2008
***************
*** 3730,3735 ****
--- 3730,3736 ----
int read_quit = 0;
Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
int we_locked_file = 0;
+ Lisp_Object original_undo_list = current_buffer->undo_list;
if (current_buffer->base_buffer && ! NILP (visit))
error ("Cannot do file visiting in an indirect buffer");
***************
*** 4589,4594 ****
--- 4590,4610 ----
current_buffer->enable_multibyte_characters = Qnil;
}
+ if (inserted > 0
+ && CONSP (current_buffer->undo_list)
+ && (! NILP (XCAR (current_buffer->undo_list))))
+ /* Insert an undo boundary unless there's one here. */
+ current_buffer->undo_list =
+ Fcons (Qnil, current_buffer->undo_list);
+ else if (inserted > 0
+ && (! EQ (original_undo_list, Qt))
+ && (NILP (visit)) && (NILP (replace)))
+ /* Assure that the first insertion is counted as a change. */
+ {
+ current_buffer->undo_list = Qnil;
+ record_first_change ();
+ }
+
coding.dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
if (CODING_MAY_REQUIRE_DECODING (&coding)
&& (inserted > 0 || CODING_REQUIRE_FLUSHING (&coding)))
Re: undo weirdness with insert-file-contents, Glenn Morris, 2008/02/28
Re: undo weirdness with insert-file-contents, Bill Wohler, 2008/02/29