From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Nordl=F6w?= Newsgroups: gmane.emacs.help Subject: Atomic Macro Calls Date: Mon, 3 May 2010 06:07:59 -0700 (PDT) Organization: http://groups.google.com Message-ID: <55484925-0837-4f50-b236-dccd96797c6e@d19g2000yqf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1273016572 9923 80.91.229.12 (4 May 2010 23:42:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 May 2010 23:42:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 05 01:42:51 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9RlK-0008Bw-LA for geh-help-gnu-emacs@m.gmane.org; Wed, 05 May 2010 01:42:50 +0200 Original-Received: from localhost ([127.0.0.1]:38318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9RlK-0005p8-3a for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 19:42:50 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!d19g2000yqf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 150.227.15.253 Original-X-Trace: posting.google.com 1272892079 3220 127.0.0.1 (3 May 2010 13:07:59 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 3 May 2010 13:07:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d19g2000yqf.googlegroups.com; posting-host=150.227.15.253; posting-account=ytJKAgoAAAA1tg4ScoRszebXiIldA5vg User-Agent: G2/1.0 X-HTTP-Via: 1.1 ip1-w.foi.se:8080 (IronPort-WSA/6.3.3-015) X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.7 (KHTML, like Gecko) Chrome/5.0.391.0 Safari/533.7,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:177887 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73298 Archived-At: 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=F6w