all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de>
Cc: emacs-devel@gnu.org
Subject: Re: undoing changes automatically
Date: Mon, 12 Nov 2007 21:12:57 +0100	[thread overview]
Message-ID: <853avbp6ie.fsf@lola.goethe.zz> (raw)
In-Reply-To: <18231.43165.842097.720674@tfkp07.physik.uni-erlangen.de> (Roland Winkler's message of "Mon, 12 Nov 2007 02:13:01 +0100")

"Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de> writes:

> Who can please explain to me the following?
>
> bibtex.el contains the function bibtex-format-entry that performs
> various formatting operations on a BibTeX entry. Along the way, it
> also checks in several ways whether syntax and content of the entry
> are correct. It throws an error if any of these checks indicates
> that something is incorrect. But this happens while it is in the
> midst of its formatting job. This is very confusing because it
> leaves the buffer in an odd state. One always needs to do an `undo'
> after such an error message.
>
> So I want to put the call to undo in the code such that it undoes
> all the formatting before it throws the error.

atomic-change-group is a Lisp macro in `subr.el'.
(atomic-change-group &rest BODY)

Perform BODY as an atomic change group.
This means that if BODY exits abnormally,
all of its changes to the current buffer are undone.
This works regardless of whether undo is enabled in the buffer.

This mechanism is transparent to ordinary use of undo;
if undo is enabled in the buffer and BODY succeeds, the
user can undo the change normally.


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  parent reply	other threads:[~2007-11-12 20:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12  1:13 undoing changes automatically Roland Winkler
2007-11-12 10:07 ` Johan Bockgård
2007-11-12 21:23   ` Leo
2007-11-12 20:12 ` David Kastrup [this message]
2007-11-12 21:21   ` Roland Winkler
2007-11-13 20:03     ` Richard Stallman
2007-11-13 21:11       ` Stefan Monnier
2007-11-15  5:06       ` Roland Winkler
2008-01-09  1:51       ` Roland Winkler
2008-01-09  5:24         ` Stefan Monnier
2008-01-09  9:10           ` Roland Winkler
2008-01-09 10:11             ` Roland Winkler
2008-01-09 15:07               ` Stefan Monnier
2008-01-10 12:20                 ` Richard Stallman
2008-01-10 14:43                   ` Stefan Monnier
2008-01-11 13:58                     ` Richard Stallman

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=853avbp6ie.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=Roland.Winkler@physik.uni-erlangen.de \
    --cc=emacs-devel@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.