[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: disabling undo boundaries

From: Phillip Lord
Subject: Re: disabling undo boundaries
Date: Tue, 12 May 2015 12:52:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Stefan Monnier <address@hidden> writes:
> Shouldn't it be sufficient to keep track of the lower bound of the
> changes, the higher bound of the changes, and the number of chars
> added/removed?
> Oh, wait I think I now remember that your two buffers aren't necessarily
> identical, in which case indeed it's ...hmm... difficult.

Yes, that's the problem. Also, it's not ideal for large changes which
span the buffer.

>> It's rather more sinister than that. The code is this:
>>   if ((current_buffer != last_undo_buffer)
>>          && (MODIFF > SAVE_MODIFF))
>>      Fundo_boundary ();
>>   last_undo_buffer = current_buffer;
>> So, when the after-change-function runs the buffer-undo-list has
>> *already* been modified. But if the a-c-f function makes an undoable
>> change, then last_undo_buffer gets reset to the other buffer (*scratch*
>> in my case).
>> Now, the *next* change happens, and current_buffer != last_undo_buffer
>> is true, so we add a boundary BEFORE, we add the next undo. So, the
>> buffer change in a-c-f adds a boundary before the next change not after
>> the one that has just been added.
> Hmm... so, IIUC the changes in *scratch* done from a-f-c cause the next
> modification in the main buffer to have an undo-boundary prepended
> because when the new command is run, last_undo_buffer is *scratch*.

Yep, that's how I read it.

> Then maybe you could try a hack like:
>    (with-current-buffer "*scratch*"
>      <doyourthing>)
>    (let ((buffer-undo-list))
>      (undo-boundary))           ; Set last_undo_buffer.

It doesn't unfortunately. An undo-boundary is not actually an undoable
action in that sense. I tried:

(save-excursion (goto-char (point-min)))

but AFAICT that fails also. I guess save-excursion is clever enough to
remove last_undo_buffer also.

>> I haven't used this for my daily emacs yet, so perhaps there are demons
>> lurking, but my question would be, why should a undoable change in
>> *that* buffer cause a marker boundary in *this*? What is the point of
>> these undo-boundaries that are causing me all this grief?
> It's a heuristic,

It is, and one that has been in Emacs for a long time. How wedded to
keeping it are you? Would it be possible to optionalize?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]