From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: harven Newsgroups: gmane.emacs.help Subject: Re: Stop a macro from terminating on beep Date: Thu, 02 Apr 2009 11:28:45 +0200 Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1238665328 9650 80.91.229.12 (2 Apr 2009 09:42:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Apr 2009 09:42:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 02 11:43:26 2009 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.50) id 1LpJS9-0004OP-7Q for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Apr 2009 11:43:17 +0200 Original-Received: from localhost ([127.0.0.1]:40619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpJQl-00007x-0f for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Apr 2009 05:41:51 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!t-online.de!tiscali!newsfeed1.ip.tiscali.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-b.proxad.net!nnrp15-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin) Cancel-Lock: sha1:ddL/f4cggCoON6mCeuydTIh9aw0= Original-Lines: 31 Original-NNTP-Posting-Date: 02 Apr 2009 11:28:45 MEST Original-NNTP-Posting-Host: 82.240.200.149 Original-X-Trace: 1238664525 news-1.free.fr 6851 82.240.200.149:50908 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:168160 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:63445 Archived-At: kazza765 writes: > Hi > > So, basically I'm trying to do what the title suggests. I have a macro that > searches through a file, finds an instance of the text I'm looking for, and > deletes the next three lines. I then have another macro that runs > \C-u10000000\C-[xname-of-macro \C-x\C-s\C-x\C-c , so I want it to exit after > tha macro is finished. This works fine in macros that don't cause a beep, > and I can run them using emacs -f name-of-macro, but the system beep that > occurs when this macro can't find any more matching patterns causes the > macro to abort, and doesn't execute the save and quit commands. Is there any > way around this? Or is there any better way to execute a search macro an > unknown number of times and still have emacs exit afterwards? I think you want condition-case. The following command executes the current macro as many time as possible, but goes to the end of buffer instead of beeping and aborting on the final error. Replace end-of-buffer by save-buffers-kill-emacs if you want to quit emacs instead of going to the end of the buffer. (defun exec-macro-without-error () "exec current macro repeatedly until an error is encountered, but don't beep and report error. Instead go to the end of buffer." (interactive) (condition-case nil (kmacro-end-or-call-macro 0) (error (end-of-buffer)))) See Handling Errors in the elisp manual for details.