[Top][All Lists]

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

About advices.

From: Constantin Kulikov
Subject: About advices.
Date: Wed, 27 Nov 2013 12:19:31 +0400

What the right way to use advices? (I know that best way it to not use it
at all.;))

At my current level of understanding:

1) You declare advices with `defadvice'. (acces arguments of original
function by `ad-get-arg').
(defadvice switch-to-buffer (after my-switch-to-buffer-advice)
  (let ((buf (ad-get-arg 0)))
    do something))

2) Then you call `ad-activate'.
Example: (ad-activate 'switch-to-buffer)
The problem here is that it will activate all advices for that function
that were defined before this `ad-activate' call, not only

3) I'm not sure. You can enable/disable certain advices with
`ad-enable-advice'/`ad-disable-advice'. Example:
(ad-disable-advice 'switch-to-buffer 'after 'my-switch-to-buffer-advice)

4) `ad-deactivate' will disable all advices for function.
Example: (ad-deactivate 'switch-to-buffer)

Am I right?

reply via email to

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