all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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: Mon, 22 Apr 2024 09:33:47 +0200	[thread overview]
Message-ID: <86il09g8bo.fsf@p200300d6272f1758742b590e6df1ee48.dip0.t-ipconnect.de> (raw)
In-Reply-To: <jwvmspmpyaz.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 21 Apr 2024 10:54:07 -0400")

Hi Stefan,

> Very interesting point.  Indeed, this is missing.
> Hmm... not completely sure how to expose that info through this new API.
> Maybe a concrete example would help figure out how to make that work.
> Do you remember how you used (or why you needed) `undo-in-progress`?

The short version: The package makes it easier to add CriticMarkup to a
document, i.e., markup to indicate additions, deletions, etc. There are
keybindings for the various markups (`{++...++}` for additions, `{--...--}` for
deletions, etc.).

The follow-changes mode tries to do that automatically: if you delete a word,
instead of actually deleting it, the word is enclosed in deletion markup.

What actually happens in the current implementation is that the text is deleted
(as per normal) and then reinserted in the buffer with deletion markup around it
(in a function in `after-change-functions`).

Similarly for an addition, instead of just inserting the new text, it is
inserted and enclosed in addition markup. That part happens in
`before-change-functions` in the current implementation.

Both hook functions start with `(unless undo-in-progress...)`, so when a change
is triggered by undo, they don't do anything special, and Emacs Does The
Right Thing. The Right Thing here being removing the mark-up, keeping the text
if the original action was a deletion and removing the text if the original
action was an addition. I assume the right thing happens because the changes
made to the buffer in the hook functions are recorded in the same change that
triggers the hooks.

It's probably easier to understand when you look at the code: 

https://github.com/joostkremers/criticmarkup-emacs/blob/master/cm-mode.el#L863

Hope this makes it clearer...

Joost



-- 
Joost Kremers
Life has its moments



  reply	other threads:[~2024-04-22  7:33 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 [this message]
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

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

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

  git send-email \
    --in-reply-to=86il09g8bo.fsf@p200300d6272f1758742b590e6df1ee48.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.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.