emacs-devel
[Top][All Lists]
Advanced

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

Re: undoing changes automatically


From: David Kastrup
Subject: Re: undoing changes automatically
Date: Mon, 12 Nov 2007 21:12:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

"Roland Winkler" <address@hidden> 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




reply via email to

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