[Top][All Lists]

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

Re: How to use defadvice without infinite loop

From: Ivan Kanis
Subject: Re: How to use defadvice without infinite loop
Date: 29 Sep 2003 06:58:02 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

    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."
  ;; 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   |
|                                                  |      |

reply via email to

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