36 |
* Preactivation:: Preactivation is a way of speeding up the |
* Preactivation:: Preactivation is a way of speeding up the |
37 |
loading of compiled advice. |
loading of compiled advice. |
38 |
* Argument Access in Advice:: How advice can access the function's arguments. |
* Argument Access in Advice:: How advice can access the function's arguments. |
39 |
* Subr Arguments:: Accessing arguments when advising a primitive. |
* Advising Primitives:: Accessing arguments when advising a primitive. |
40 |
* Combined Definition:: How advice is implemented. |
* Combined Definition:: How advice is implemented. |
41 |
@end menu |
@end menu |
42 |
|
|
331 |
@cindex advice, activating |
@cindex advice, activating |
332 |
|
|
333 |
By default, advice does not take effect when you define it---only when |
By default, advice does not take effect when you define it---only when |
334 |
you @dfn{activate} advice for the function that was advised. You can |
you @dfn{activate} advice for the function that was advised. However |
335 |
request the activation of advice for a function when you define the |
the advice will be automatically activated if the function is defined |
336 |
advice, by specifying the @code{activate} flag in the @code{defadvice}. |
or redefined later. You can request the activation of advice for a |
337 |
But normally you activate the advice for a function by calling the |
function when you define the advice, by specifying the @code{activate} |
338 |
function @code{ad-activate} or one of the other activation commands |
flag in the @code{defadvice}. But normally you activate the advice |
339 |
listed below. |
for a function by calling the function @code{ad-activate} or one of |
340 |
|
the other activation commands listed below. |
341 |
|
|
342 |
Separating the activation of advice from the act of defining it permits |
Separating the activation of advice from the act of defining it permits |
343 |
you to add several pieces of advice to one function efficiently, without |
you to add several pieces of advice to one function efficiently, without |
417 |
|
|
418 |
@deffn Command ad-start-advice |
@deffn Command ad-start-advice |
419 |
Turn on automatic advice activation when a function is defined or |
Turn on automatic advice activation when a function is defined or |
420 |
redefined. If you turn on this mode, then advice takes effect |
redefined. This is the default mode. |
|
immediately when defined. |
|
421 |
@end deffn |
@end deffn |
422 |
|
|
423 |
@deffn Command ad-stop-advice |
@deffn Command ad-stop-advice |
656 |
These argument constructs are not really implemented as Lisp macros. |
These argument constructs are not really implemented as Lisp macros. |
657 |
Instead they are implemented specially by the advice mechanism. |
Instead they are implemented specially by the advice mechanism. |
658 |
|
|
659 |
@node Subr Arguments |
@node Advising Primitives |
660 |
@section Definition of Subr Argument Lists |
@section Advising Primitives |
661 |
|
|
662 |
When the advice facility constructs the combined definition, it needs |
Advising a primitive function (also called a ``subr'') is risky. |
663 |
to know the argument list of the original function. This is not always |
Some primitive functions are used by the advice mechanism; advising |
664 |
possible for primitive functions. When advice cannot determine the |
them could cause an infinite recursion. Also, many primitive |
665 |
argument list, it uses @code{(&rest ad-subr-args)}, which always works |
functions are called directly from C code. Calls to the primitive |
666 |
but is inefficient because it constructs a list of the argument values. |
from Lisp code will take note of the advice, but calls from C code |
667 |
You can use @code{ad-define-subr-args} to declare the proper argument |
will ignore the advice. |
668 |
names for a primitive function: |
|
669 |
|
When the advice facility constructs the combined definition, it needs |
670 |
|
to know the argument list of the original function. This is not |
671 |
|
always possible for primitive functions. When advice cannot determine |
672 |
|
the argument list, it uses @code{(&rest ad-subr-args)}, which always |
673 |
|
works but is inefficient because it constructs a list of the argument |
674 |
|
values. You can use @code{ad-define-subr-args} to declare the proper |
675 |
|
argument names for a primitive function: |
676 |
|
|
677 |
@defun ad-define-subr-args function arglist |
@defun ad-define-subr-args function arglist |
678 |
This function specifies that @var{arglist} should be used as the |
This function specifies that @var{arglist} should be used as the |
751 |
executed even if some previous piece of advice had an error or a |
executed even if some previous piece of advice had an error or a |
752 |
non-local exit. If any around-advice is protected, then the whole |
non-local exit. If any around-advice is protected, then the whole |
753 |
around-advice onion is protected as a result. |
around-advice onion is protected as a result. |
754 |
|
|
755 |
|
@ignore |
756 |
|
arch-tag: 80c135c2-f1c3-4f8d-aa85-f8d8770d307f |
757 |
|
@end ignore |