unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Editing change groups
@ 2018-11-09  7:52 Michael Heerdegen
  2018-11-09  8:39 ` Joost Kremers
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Michael Heerdegen @ 2018-11-09  7:52 UTC (permalink / raw)
  To: Emacs mailing list

Hello,

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 ()
  (interactive)
  (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
all.

Seems I'm missing something?


Thanks,

Michael.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-11-11  8:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3697.1541749970.1284.help-gnu-emacs@gnu.org>
2018-11-09 11:41 ` Editing change groups Ben Bacarisse
2018-11-09 12:10   ` Michael Heerdegen
     [not found]   ` <mailman.3721.1541765458.1284.help-gnu-emacs@gnu.org>
2018-11-09 13:36     ` Ben Bacarisse
2018-11-09 13:58       ` Michael Heerdegen
2018-11-09  7:52 Michael Heerdegen
2018-11-09  8:39 ` Joost Kremers
2018-11-09 11:58 ` Noam Postavsky
2018-11-09 12:39   ` Michael Heerdegen
2018-11-09 13:14     ` Eli Zaretskii
2018-11-09 13:12 ` Michael Heerdegen
2018-11-09 13:52 ` Stefan Monnier
2018-11-10  4:53   ` Michael Heerdegen
2018-11-10 13:15     ` Stefan Monnier
2018-11-10 16:23       ` Michael Heerdegen
2018-11-10 18:07         ` Stefan Monnier
2018-11-11  8:01           ` Michael Heerdegen

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