unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: phillip.lord@newcastle.ac.uk (Phillip Lord)
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: disabling undo boundaries
Date: Mon, 11 May 2015 18:23:59 -0400	[thread overview]
Message-ID: <jwvd226wyj3.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87oalqrgm7.fsf@newcastle.ac.uk> (Phillip Lord's message of "Mon,  11 May 2015 21:42:08 +0100")

[ 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	other threads:[~2015-05-11 22:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-10 21:43 disabling undo boundaries Phillip Lord
2015-05-11  1:42 ` Stefan Monnier
2015-05-11 11:46   ` Phillip Lord
2015-05-11 14:45     ` Stefan Monnier
2015-05-11 16:31       ` Phillip Lord
2015-05-11 19:30         ` Stefan Monnier
2015-05-11 20:42           ` Phillip Lord
2015-05-11 22:23             ` Stefan Monnier [this message]
2015-05-12 11:52               ` Phillip Lord
2015-05-12 20:15                 ` Stefan Monnier
2015-05-12 20:59                   ` Phillip Lord
2015-05-13 12:32                     ` Stefan Monnier
2015-05-13 15:40                       ` Phillip Lord
2015-05-14 15:28                         ` Stefan Monnier
2015-05-15 12:27                           ` Phillip Lord
2015-05-15 18:08                             ` Stefan Monnier
2015-05-15 19:49                               ` Phillip Lord
2015-05-15 23:45                                 ` Stefan Monnier
2015-05-16 13:31                                   ` Phillip Lord
2015-05-19 11:59                                     ` Phillip Lord
2015-05-19 19:42                                       ` Stefan Monnier
2015-05-19 21:48                                         ` Phillip Lord
2015-05-20  2:00                                           ` Stefan Monnier
2015-05-20  7:45                                             ` Phillip Lord
2015-05-20 12:53                                               ` Stefan Monnier
2015-05-21 11:15                                                 ` Phillip Lord
2015-05-21 15:44                                                   ` Stefan Monnier
2015-05-21 17:03                                                     ` Phillip Lord
2015-05-27 11:46                                                       ` Phillip Lord
2015-06-29  0:46                                                         ` Stefan Monnier
2015-08-04 14:18                                                           ` Phillip Lord
2015-08-06 21:02                                                             ` Phillip Lord
2015-08-06 22:20                                                             ` Stefan Monnier
2015-08-07 13:40                                                               ` Phillip Lord
2015-08-07 13:59                                                                 ` David Kastrup
2015-08-07 21:10                                                                   ` Phillip Lord
2015-08-08  5:39                                                                     ` David Kastrup
2015-08-08  9:58                                                                       ` Phillip Lord
2015-08-07 17:10                                                                 ` Stefan Monnier
2015-08-08 21:28                                                                   ` Stefan Monnier
2015-08-09 15:39                                                                     ` Phillip Lord
2015-08-09 16:30                                                                       ` Stefan Monnier
2015-08-09 16:50                                                                         ` Phillip Lord
2015-08-09 17:40                                                                           ` Stefan Monnier
2015-08-10  9:27                                                                             ` Phillip Lord
2015-08-10 21:21                                                                               ` Phillip Lord
2015-08-12 21:15                                                                               ` Stefan Monnier
2015-08-12 22:34                                                                                 ` Phillip Lord
2015-08-13  2:23                                                                                   ` Stefan Monnier
2015-08-21  9:40                                                                                     ` Phillip Lord
2015-08-07 23:49                                                     ` Davis Herring
2015-08-08 10:01                                                       ` Phillip Lord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd226wyj3.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=phillip.lord@newcastle.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).