unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Joost Kremers <joostkremers@fastmail.fm>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" <help-gnu-emacs@gnu.org>
Subject: Re: track-changes and undo
Date: Tue, 23 Apr 2024 09:06:10 +0200	[thread overview]
Message-ID: <868r14o8wt.fsf@p200300d6272f172e0e35ca5d92eef483.dip0.t-ipconnect.de> (raw)
In-Reply-To: <jwvo7a1j9op.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 22 Apr 2024 19:04:10 -0400")

On Mon, Apr 22 2024, Stefan Monnier wrote:
> In the general case it's tricky to postpone the buffer change to a safer
> time, indeed.  In practice, tho, you should be able to distinguish "undo
> commands" from all other commands (basically depending on whether they
> do all their modifications with `undo-in-progress` or not) and then
> ignore only the changes of undo commands: the result should be
> good enough.
>
> IOW something like:
[code snipped]

Thanks, I'll see if I can make it work.

>>> One other thing that you might have trouble to reproduce with
>>> `track-changes` is the following test:
>>>
>>>     (and (= beg (point-min)) (= end (point-max)))
>>>
>>> that you have in `cm-before-change`.  I'm not completely sure what this
>>> is for, tho.  Is it for `revert-buffer`?
>>
>> I honestly don't remember... Based on the comment, it looks like
>> `switch-to-buffer` triggers `before-change-functions`, but a) that doesn't make
>> much sense; and b) the code seems to work just fine without that line. (I even
>> fired up a Vagrant box with an old Ubuntu release with Emacs 24, which would be
>> the most recent version when I wrote that code).
>
> Have you tried `M-x revert-buffer RET` (assuming the file and the
> buffer aren't equal)?

I did, but that appears to resets `before-change-functions` (and presumably
`after-change-functions`). After `revert-buffer`, the function that
cm-follow-mode adds to `before-change-functions` is gone, and `cm-mode` itself
is disabled. So I doubt that was the reason for adding that line. (Also, I don't
think I would have written "buffer switches" in the comment if I actually meant
"reverting a buffer". But then again, one's past self can be quite
unpredictable...)

-- 
Joost Kremers
Life has its moments



      parent reply	other threads:[~2024-04-23  7:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-21  8:23 track-changes and undo Joost Kremers
2024-04-21 14:54 ` Stefan Monnier
2024-04-22  7:33   ` Joost Kremers
2024-04-22 12:38     ` Stefan Monnier
2024-04-22 21:41       ` Joost Kremers
2024-04-22 23:04         ` Stefan Monnier
2024-04-23  5:58           ` Eli Zaretskii
2024-04-23  7:06           ` Joost Kremers [this message]

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=868r14o8wt.fsf@p200300d6272f172e0e35ca5d92eef483.dip0.t-ipconnect.de \
    --to=joostkremers@fastmail.fm \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
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).