From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Robert Marshall Newsgroups: gmane.emacs.help Subject: Re: How to use defadvice without infinite loop Date: Sat, 27 Sep 2003 21:22:06 +0100 Organization: The first against the wall Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87d6dm1d5t.fsf@juliva.com> Reply-To: robert@chezmarshall.freeserve.co.uk NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1064694716 16731 80.91.224.253 (27 Sep 2003 20:31:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 27 Sep 2003 20:31:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 27 22:31:54 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A3LjO-0000Ev-00 for ; Sat, 27 Sep 2003 22:31:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A3LiO-00007s-FE for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Sep 2003 16:30:52 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!diablo.theplanet.net!newspeer1-gui.server.ntli.net!ntli.net!newsfep4-winn.server.ntli.net.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help X-Home-Page: http://www.chezmarshall.freeserve.co.uk User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:xtwm5b5GURifrW1SBSI8/Doz6is= Original-Lines: 33 Original-NNTP-Posting-Host: 213.104.252.51 Original-X-Complaints-To: abuse@ntlworld.com Original-X-Trace: newsfep4-winn.server.ntli.net 1064694234 213.104.252.51 (Sat, 27 Sep 2003 21:23:54 BST) Original-NNTP-Posting-Date: Sat, 27 Sep 2003 21:23:54 BST Original-Xref: shelby.stanford.edu gnu.emacs.help:116913 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12839 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12839 On 27 Sep 2003, Ivan Kanis wrote: > I want to save VM files to _always_ be saved before calling the > function save-some buffers. > > I am tired of answering 'yes' for these files when grepping, > compiling or quiting emacs. > > I came up with a defadvice function but the proble is that it's > calling save-some-buffers and it produces an infinite loop. Is there > a way to avoid that? > > (defadvice save-some-buffers(before my-save-some-buffers activate) > "Ask to save buffers." > (interactive) > (save-some-buffers nil 'my-always-save)) > > (defun my-always-save() > "Files to always save." > (when buffer-file-name > (when (string-match "^/home/ivank/mail" buffer-file-name) > (save-buffer)))) > use (ad-set-arg 1 'my-always-save) and don't call save-some-buffers in the advice (totally untested... but the info on 'Argument Access in Advice' is worth reading) Robert -- La grenouille songe..dans son château d'eau