all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Editing change groups
Date: Fri, 09 Nov 2018 08:52:16 +0100	[thread overview]
Message-ID: <87sh0an0wf.fsf@web.de> (raw)

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.



             reply	other threads:[~2018-11-09  7:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09  7:52 Michael Heerdegen [this message]
2018-11-09  8:39 ` Editing change groups 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
     [not found] <mailman.3697.1541749970.1284.help-gnu-emacs@gnu.org>
2018-11-09 11:41 ` 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

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=87sh0an0wf.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.