[Top][All Lists]

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

Editing change groups

From: Michael Heerdegen
Subject: Editing change groups
Date: Fri, 09 Nov 2018 08:52:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)


I have the following requirement for a user interface: if the user hits
a key, something in the buffer is replaced with something else.  Doing
this potentially involves several editing operations.  If the user hits
the same key again, the old contents are restored.

My question is: are change groups, as described in (info "(elisp) Atomic
Changes"), a suitable tool to do this?  AFAIK it works, but I must admit
I don't understand the implementation of change groups.  I tried to use
an example like

(defun my-test-change-groups ()
  (insert "0\n")
  (let ((g (prepare-change-group)))
    (insert "a\n")
    (activate-change-group g)
    (insert "b\n")
    (insert "c\n")
    (cancel-change-group g)))

to see how things work but that doesn't work as I expected: calling the
command leaves all insertions intact as if the change group G hadn't
been canceled.  OTOH, if I remove the first insertion (insert "0\n")
from the example, calling the function causes nothing to be inserted at

Seems I'm missing something?



reply via email to

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