Function: ad-activate
ad-activate is an autoloaded, interactive and byte-compiled function
defined in advice.el.gz.
Signature
(ad-activate FUNCTION &optional COMPILE)
Documentation
Activate all the advice information of an advised FUNCTION.
If FUNCTION has a proper original definition then an advised
definition will be generated from FUNCTION's advice info and the
definition of FUNCTION will be replaced with it. If a previously
cached advised definition was available, it will be used.
The optional COMPILE argument determines whether the resulting function
or a compilable cached definition will be compiled. If it is negative
no compilation will be performed, if it is positive or otherwise non-nil
the resulting function will be compiled, if it is nil the behavior depends
on the value of ad-default-compilation-action (which see).
Activation of an advised function that has an advice info but no actual
pieces of advice is equivalent to a call to ad-unadvise. Activation of
an advised function that has actual pieces of advice but none of them are
enabled is equivalent to a call to ad-deactivate. The current advised
definition will always be cached for later usage.
Key Bindings
Aliases
ad-activate-internal
ad-activate-on
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
;; @@ The top-level advice interface:
;; ==================================
;;;###autoload
(defun ad-activate (function &optional compile)
"Activate all the advice information of an advised FUNCTION.
If FUNCTION has a proper original definition then an advised
definition will be generated from FUNCTION's advice info and the
definition of FUNCTION will be replaced with it. If a previously
cached advised definition was available, it will be used.
The optional COMPILE argument determines whether the resulting function
or a compilable cached definition will be compiled. If it is negative
no compilation will be performed, if it is positive or otherwise non-nil
the resulting function will be compiled, if it is nil the behavior depends
on the value of `ad-default-compilation-action' (which see).
Activation of an advised function that has an advice info but no actual
pieces of advice is equivalent to a call to `ad-unadvise'. Activation of
an advised function that has actual pieces of advice but none of them are
enabled is equivalent to a call to `ad-deactivate'. The current advised
definition will always be cached for later usage."
(interactive
(list (ad-read-advised-function "Activate advice of")
current-prefix-arg))
(cond
((not (ad-is-advised function))
(error "ad-activate: `%s' is not advised" function))
;; Just return for forward advised and not yet defined functions:
((not (ad-get-orig-definition function)) nil)
((not (ad-has-any-advice function)) (ad-unadvise function))
;; Otherwise activate the advice:
((ad-has-redefining-advice function)
(ad-activate-advised-definition function compile)
(ad-set-advice-info-field function 'active t)
(eval (ad-make-hook-form function 'activation))
function)
;; Here we are if we have all disabled advices:
(t (ad-deactivate function))))