Next: Porting old advice, Previous: Advising Named Functions, Up: Advising Functions
Here are the different possible values for the where argument of
add-function and advice-add, specifying how the advice
function and the original function should be composed.
:before(lambda (&rest r) (apply function r) (apply oldfun r))
(add-function :before funvar function) is comparable for
single-function hooks to (add-hook 'hookvar function) for
normal hooks.
:after(lambda (&rest r) (prog1 (apply oldfun r) (apply function r)))
(add-function :after funvar function) is comparable for
single-function hooks to (add-hook 'hookvar function
'append) for normal hooks.
:overrideremove-function.
:around(lambda (&rest r) (apply function oldfun r))
:before-whilenil. Both functions receive the
same arguments, and the return value of the composition is the return value of
the old function. More specifically, the composition of the two functions
behaves like:
(lambda (&rest r) (and (apply function r) (apply oldfun r)))
(add-function :before-while funvar function) is comparable
for single-function hooks to (add-hook 'hookvar function)
when hookvar is run via run-hook-with-args-until-failure.
:before-untilnil. More specifically, the composition of the
two functions behaves like:
(lambda (&rest r) (or (apply function r) (apply oldfun r)))
(add-function :before-until funvar function) is comparable
for single-function hooks to (add-hook 'hookvar function)
when hookvar is run via run-hook-with-args-until-success.
:after-whilenil. Both functions receive the same arguments, and the
return value of the composition is the return value of function.
More specifically, the composition of the two functions behaves like:
(lambda (&rest r) (and (apply oldfun r) (apply function r)))
(add-function :after-while funvar function) is comparable
for single-function hooks to (add-hook 'hookvar function
'append) when hookvar is run via
run-hook-with-args-until-failure.
:after-untilnil. More specifically, the composition of the two functions
behaves like:
(lambda (&rest r) (or (apply oldfun r) (apply function r)))
(add-function :after-until funvar function) is comparable
for single-function hooks to (add-hook 'hookvar function
'append) when hookvar is run via
run-hook-with-args-until-success.
:filter-args(lambda (&rest r) (apply oldfun (funcall function r)))
:filter-return(lambda (&rest r) (funcall function (apply oldfun r)))