>>+ current_buffer->undo_list = >>+ Fcons (Qnil, current_buffer->undo_list); > > > We should use Fundo_boundary here. OK - tho' I'm not sure whether pending_boundary should be considered here. Note that I could remove that boundary and also combine the insertion with a previous one if that's desired. Personally, I'd prefer to undo two separate insertions from files separately. In this context note that record_insert combines two insertions only if they happen in a left-to-right way. IIUC this should be eventually changed when Emacs goes bi-directional. >>+ 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 (); >>+ } > > > You use `else' between the two, but it's not clear why the two should be > mutually exclusive. And please mention `visit' in the comment. It's hopefully a bit clearer now although I'm not sure whether I need the empty_undo_list check at all. BTW, what is the semantics of `insert-file-contents' with VISIT nil and REPLACE non-nil? > Also if the file is empty, is this going to mark the buffer as modified > even though nothing was changed? I'm afraid I don't understand the question - do you mean the case where inserted equals zero? I don't handle that. But maybe I'm missing something.