emacs-devel
[Top][All Lists]
Advanced

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

Re: disabling undo boundaries


From: Stefan Monnier
Subject: Re: disabling undo boundaries
Date: Mon, 11 May 2015 18:23:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

[ FWIW, I'm not sure amalgamating would actually help solve this
  problem.  ]

> It's difficult in my case. The problem is I have two buffers which I am
> keeping in sync. So I need to be able to convert a point location in one
> with a point location in another. And I have to do this *before* the
> change happens because otherwise the two buffers will hold content which
> is not in sync (one has changed, the other hasn't been updated yet).

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.

> 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*.

Then maybe you could try a hack like:

   (with-current-buffer "*scratch*"
     <doyourthing>)
   (let ((buffer-undo-list))
     (undo-boundary))           ; Set last_undo_buffer.

>> Since `doyourthing' shouldn't touch the source buffer, the source
>> buffer's undo-list has no reason to have a hand-added undo-boundary.
> In between the start and end of a command?

No: during your a-f-c.

> 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,


        Stefan





reply via email to

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