diff options
| author | Richard M. Stallman | 2005-02-26 23:49:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-02-26 23:49:49 +0000 |
| commit | 8389b33fa2a8cdcee34adc84bd86b85ec8a101e3 (patch) | |
| tree | 270d5103b19cb71395b26b2bccd4578d7fcb124a | |
| parent | a7cc2e20fd266ebcf0a325878415d5e067243f4a (diff) | |
| download | emacs-8389b33fa2a8cdcee34adc84bd86b85ec8a101e3.tar.gz emacs-8389b33fa2a8cdcee34adc84bd86b85ec8a101e3.zip | |
(Advising Functions): Don't imply one part of Emacs
should advise another part. Markup changes.
(Defining Advice): Move transitional para.
(Activation of Advice): Cleanup.
Explain if COMPILE is nil or negative.
| -rw-r--r-- | lispref/advice.texi | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lispref/advice.texi b/lispref/advice.texi index ae22fecc1fb..2006474fc61 100644 --- a/lispref/advice.texi +++ b/lispref/advice.texi | |||
| @@ -7,15 +7,15 @@ | |||
| 7 | @chapter Advising Emacs Lisp Functions | 7 | @chapter Advising Emacs Lisp Functions |
| 8 | @cindex advising functions | 8 | @cindex advising functions |
| 9 | 9 | ||
| 10 | The @dfn{advice} feature lets you add to the existing definition of a | 10 | The @dfn{advice} feature lets you add to the existing definition of |
| 11 | function, by @dfn{advising the function}. This is a clean method for a | 11 | a function, by @dfn{advising the function}. This is a clean method |
| 12 | library to customize functions defined by other parts of Emacs---cleaner | 12 | for a library to customize functions defined within Emacs---cleaner |
| 13 | than redefining the whole function. | 13 | than redefining the whole function. |
| 14 | 14 | ||
| 15 | @cindex piece of advice | 15 | @cindex piece of advice |
| 16 | Each function can have multiple @dfn{pieces of advice}, separately | 16 | Each function can have multiple @dfn{pieces of advice}, separately |
| 17 | defined. Each defined piece of advice can be @dfn{enabled} or | 17 | defined. Each defined piece of advice can be @dfn{enabled} or |
| 18 | disabled explicitly. All the enabled pieces of advice for any given | 18 | @dfn{disabled} explicitly. All the enabled pieces of advice for any given |
| 19 | function actually take effect when you @dfn{activate} advice for that | 19 | function actually take effect when you @dfn{activate} advice for that |
| 20 | function, or when you define or redefine the function. Note that | 20 | function, or when you define or redefine the function. Note that |
| 21 | enabling a piece of advice and activating advice for a function | 21 | enabling a piece of advice and activating advice for a function |
| @@ -129,6 +129,9 @@ form) to be advised. From now on, we will write just ``function'' when | |||
| 129 | describing the entity being advised, but this always includes macros and | 129 | describing the entity being advised, but this always includes macros and |
| 130 | special forms. | 130 | special forms. |
| 131 | 131 | ||
| 132 | In place of the argument list in an ordinary definition, an advice | ||
| 133 | definition calls for several different pieces of information. | ||
| 134 | |||
| 132 | @cindex class of advice | 135 | @cindex class of advice |
| 133 | @cindex before-advice | 136 | @cindex before-advice |
| 134 | @cindex after-advice | 137 | @cindex after-advice |
| @@ -154,9 +157,6 @@ the pieces of advice in a particular class for a particular | |||
| 154 | @var{function}. The name allows you to refer to the piece of | 157 | @var{function}. The name allows you to refer to the piece of |
| 155 | advice---to redefine it, or to enable or disable it. | 158 | advice---to redefine it, or to enable or disable it. |
| 156 | 159 | ||
| 157 | In place of the argument list in an ordinary definition, an advice | ||
| 158 | definition calls for several different pieces of information. | ||
| 159 | |||
| 160 | The optional @var{position} specifies where, in the current list of | 160 | The optional @var{position} specifies where, in the current list of |
| 161 | advice of the specified @var{class}, this new advice should be placed. | 161 | advice of the specified @var{class}, this new advice should be placed. |
| 162 | It should be either @code{first}, @code{last} or a number that specifies | 162 | It should be either @code{first}, @code{last} or a number that specifies |
| @@ -332,9 +332,9 @@ replaced with the new one. | |||
| 332 | @cindex advice, activating | 332 | @cindex advice, activating |
| 333 | 333 | ||
| 334 | By default, advice does not take effect when you define it---only when | 334 | By default, advice does not take effect when you define it---only when |
| 335 | you @dfn{activate} advice for the function that was advised. However | 335 | you @dfn{activate} advice for the function that was advised. However, |
| 336 | the advice will be automatically activated if the function is defined | 336 | the advice will be activated automatically if you define or redefine |
| 337 | or redefined later. You can request the activation of advice for a | 337 | the function later. You can request the activation of advice for a |
| 338 | function when you define the advice, by specifying the @code{activate} | 338 | function when you define the advice, by specifying the @code{activate} |
| 339 | flag in the @code{defadvice}. But normally you activate the advice | 339 | flag in the @code{defadvice}. But normally you activate the advice |
| 340 | for a function by calling the function @code{ad-activate} or one of | 340 | for a function by calling the function @code{ad-activate} or one of |
| @@ -353,9 +353,11 @@ are combined with the original definition to make a new definition. | |||
| 353 | @ref{Enabling Advice}.) This definition is installed, and optionally | 353 | @ref{Enabling Advice}.) This definition is installed, and optionally |
| 354 | byte-compiled as well, depending on conditions described below. | 354 | byte-compiled as well, depending on conditions described below. |
| 355 | 355 | ||
| 356 | In all of the commands to activate advice, if @var{compile} is @code{t}, | 356 | In all of the commands to activate advice, if @var{compile} is |
| 357 | the command also compiles the combined definition which implements the | 357 | @code{t} (or anything but @code{nil} or a negative number), the |
| 358 | advice. | 358 | command also compiles the combined definition which implements the |
| 359 | advice. If it is @code{nil} or a negative number, what happens | ||
| 360 | depends on @code{ad-default-compilation-action} as described below. | ||
| 359 | 361 | ||
| 360 | @deffn Command ad-activate function &optional compile | 362 | @deffn Command ad-activate function &optional compile |
| 361 | This command activates all the advice defined for @var{function}. | 363 | This command activates all the advice defined for @var{function}. |
| @@ -438,9 +440,8 @@ the advice if the original definition of the advised function is | |||
| 438 | compiled or a built-in function. | 440 | compiled or a built-in function. |
| 439 | 441 | ||
| 440 | This variable takes effect only if the @var{compile} argument of | 442 | This variable takes effect only if the @var{compile} argument of |
| 441 | @code{ad-activate} (or any of the above functions) was supplied as | 443 | @code{ad-activate} (or any of the above functions) did not force |
| 442 | @code{nil}. If that argument is non-@code{nil}, that means | 444 | compilation. |
| 443 | to compile the advice regardless. | ||
| 444 | @end defopt | 445 | @end defopt |
| 445 | 446 | ||
| 446 | If the advised definition was constructed during ``preactivation'' | 447 | If the advised definition was constructed during ``preactivation'' |