unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Robert Marshall <spam@chezmarshall.freeserve.co.uk>
Subject: Re: How to use defadvice without infinite loop
Date: Sat, 27 Sep 2003 21:22:06 +0100	[thread overview]
Message-ID: <m11xu29e35.fsf@chezmarshall.freeserve.co.uk> (raw)
In-Reply-To: 87d6dm1d5t.fsf@juliva.com

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

  reply	other threads:[~2003-09-27 20:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-27 15:09 How to use defadvice without infinite loop Ivan Kanis
2003-09-27 20:22 ` Robert Marshall [this message]
2003-09-28  5:14 ` Klaus Berndl
2003-09-29  4:58   ` Ivan Kanis
2003-09-29 15:08     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m11xu29e35.fsf@chezmarshall.freeserve.co.uk \
    --to=spam@chezmarshall.freeserve.co.uk \
    --cc=robert@chezmarshall.freeserve.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).