help-gnu-emacs
[Top][All Lists]
Advanced

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

Atomic Macro Calls


From: Nordlöw
Subject: Atomic Macro Calls
Date: Mon, 3 May 2010 06:07:59 -0700 (PDT)
User-agent: G2/1.0

Hey!

I think "the security" of macro calls in Emacs would be improved if
we, upon error during execution, queried the user for complete revert/
undo of all the effects that were made in buffers affected by this
last macro call. For the case when only a single buffer is changed the
following function could serve as a first mockup for a suitable
wrapper function that solves this problem.

(defun kmacro-call-macro-atomic (arg)
  "Call last keyboard macro.
If an error during execution ask user to revert any changes that
occurred."
  (interactive "P")
  (atomic-change-group
   (kmacro-call-macro arg)))

Unfortunately atomic-change-group does not seem to work as expected
here.
It does not revert the buffer contents but instead the function cancel-
change-group errors with the message:

    Undoing to some unrelated state

To compare with the following code changes the buffer contents only if
the search succeeds:

    (atomic-change-group (insert "x") (search-forward ";; "))

Does anybody have a better implementation of the function kmacro-call-
macro-atomic that undoes the changes made during the macro-call?

Thanks in advance for all kinds of feedback,
Per Nordlöw


reply via email to

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