[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use defadvice without infinite loop

From: Robert Marshall
Subject: Re: How to use defadvice without infinite loop
Date: Sat, 27 Sep 2003 21:22:06 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)

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))))

(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 

La grenouille songe..dans son ch√Ęteau d'eau

reply via email to

[Prev in Thread] Current Thread [Next in Thread]