From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ivan Kanis Newsgroups: gmane.emacs.help Subject: Re: How to use defadvice without infinite loop Date: 29 Sep 2003 06:58:02 +0200 Organization: Guest of TISCALI - FRANCE Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87y8w8199h.fsf@juliva.com> References: <87d6dm1d5t.fsf@juliva.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1064823558 29096 80.91.224.253 (29 Sep 2003 08:19:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2003 08:19:18 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 29 10:19:16 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 1A3tFU-0003Zo-00 for ; Mon, 29 Sep 2003 10:19:16 +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 1A3tCN-0008Ir-BT for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Sep 2003 04:16:03 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!proxad.net!news.tiscali.fr!127.0.0.1!nobody Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: 212.47.245.51 Original-X-Trace: news.tiscali.fr 1064822473 9772 212.47.245.51 (29 Sep 2003 08:01:13 GMT) Original-X-Complaints-To: abuse@libertysurf.fr Original-NNTP-Posting-Date: Mon, 29 Sep 2003 08:01:13 +0000 (UTC) Original-Sender: spam@juliva.com User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:116932 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:12858 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12858 Klaus> (defadvice save-some-buffers(before my-save-some-buffers Klaus> activate) Klaus> "Ask to save buffers." (ad-set-arg 1 'my-always-save)) Klaus> This is all...test it! It doesn't work, I need to call the function save-some-buffers twice. I am not trying to substitute it's arguments. I have found this code prevents the infinite loop, so far it seems to work well... (defadvice save-some-buffers(before my-save-some-buffers activate) "Ask to save buffers." (interactive) ;; Prevent infinite loop (ad-deactivate-regexp "my-save-some-buffers") (save-some-buffers nil 'my-always-save) (ad-activate-regexp "my-save-some-buffers")) (defun my-always-save() "Files to always save." (when buffer-file-name (when (string-match "^/home/ivank/mail" buffer-file-name) (vm-save-buffer nil)))) -- /-----------------------------------------------------------------------------* | "Love your enemy, it will drive him nuts." | Ivan Kanis | | (Eleanor Doan) | Software Developper | | | www.kanis.cc | *-----------------------------------------------------------------------------/