Mercurial > emacs
comparison lispref/advice.texi @ 90043:e24e2e78deda
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-69
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-643
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-649
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-651
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-655
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-656
Update from CVS: lisp/man.el (Man-xref-normal-file): Fix help-echo.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-657
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-658
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-659
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-660
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-661
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-667
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-61
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-68
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 04 Nov 2004 08:55:40 +0000 |
parents | 548375b6b1f8 b73dae8c28d0 |
children | e4694597cbf4 |
comparison
equal
deleted
inserted
replaced
90042:003d95404d71 | 90043:e24e2e78deda |
---|---|
49 move to if @code{next-line-add-newlines} is non-@code{nil} (its default | 49 move to if @code{next-line-add-newlines} is non-@code{nil} (its default |
50 is @code{nil}.) | 50 is @code{nil}.) |
51 | 51 |
52 Suppose you wanted to add a similar feature to @code{previous-line}, | 52 Suppose you wanted to add a similar feature to @code{previous-line}, |
53 which would insert a new line at the beginning of the buffer for the | 53 which would insert a new line at the beginning of the buffer for the |
54 command to move to. How could you do this? | 54 command to move to (when @code{next-line-add-newlines} is |
55 non-@code{nil}). How could you do this? | |
55 | 56 |
56 You could do it by redefining the whole function, but that is not | 57 You could do it by redefining the whole function, but that is not |
57 modular. The advice feature provides a cleaner alternative: you can | 58 modular. The advice feature provides a cleaner alternative: you can |
58 effectively add your code to the existing function definition, without | 59 effectively add your code to the existing function definition, without |
59 actually changing or even seeing that definition. Here is how to do | 60 actually changing or even seeing that definition. Here is how to do |
271 @noindent | 272 @noindent |
272 Its effect is to make sure that case is ignored in | 273 Its effect is to make sure that case is ignored in |
273 searches when the original definition of @code{foo} is run. | 274 searches when the original definition of @code{foo} is run. |
274 | 275 |
275 @defvar ad-do-it | 276 @defvar ad-do-it |
276 This is not really a variable, but it is somewhat used like one | 277 This is not really a variable, rather a place-holder that looks like a |
277 in around-advice. It specifies the place to run the function's | 278 variable. You use it in around-advice to specify the place to run the |
278 original definition and other ``earlier'' around-advice. | 279 function's original definition and other ``earlier'' around-advice. |
279 @end defvar | 280 @end defvar |
280 | 281 |
281 If the around-advice does not use @code{ad-do-it}, then it does not run | 282 If the around-advice does not use @code{ad-do-it}, then it does not run |
282 the original function definition. This provides a way to override the | 283 the original function definition. This provides a way to override the |
283 original definition completely. (It also overrides lower-positioned | 284 original definition completely. (It also overrides lower-positioned |
358 | 359 |
359 @deffn Command ad-activate function &optional compile | 360 @deffn Command ad-activate function &optional compile |
360 This command activates all the advice defined for @var{function}. | 361 This command activates all the advice defined for @var{function}. |
361 @end deffn | 362 @end deffn |
362 | 363 |
363 To activate advice for a function whose advice is already active is not | 364 Activating advice does nothing if @var{function}'s advice is already |
364 a no-op. It is a useful operation which puts into effect any changes in | 365 active. But if there is new advice, added since the previous time you |
365 that function's advice since the previous activation of advice for that | 366 activated advice for @var{function}, it activates the new advice. |
366 function. | |
367 | 367 |
368 @deffn Command ad-deactivate function | 368 @deffn Command ad-deactivate function |
369 This command deactivates the advice for @var{function}. | 369 This command deactivates the advice for @var{function}. |
370 @cindex deactivating advice | 370 @cindex deactivating advice |
371 @cindex advice, deactivating | 371 @cindex advice, deactivating |
428 @defopt ad-default-compilation-action | 428 @defopt ad-default-compilation-action |
429 This variable controls whether to compile the combined definition | 429 This variable controls whether to compile the combined definition |
430 that results from activating advice for a function. | 430 that results from activating advice for a function. |
431 | 431 |
432 A value of @code{always} specifies to compile unconditionally. | 432 A value of @code{always} specifies to compile unconditionally. |
433 A value of @code{nil} specifies never compile the advice. | 433 A value of @code{never} specifies never compile the advice. |
434 | 434 |
435 A value of @code{maybe} specifies to compile if the byte-compiler is | 435 A value of @code{maybe} specifies to compile if the byte-compiler is |
436 already loaded. A value of @code{like-original} specifies to compile | 436 already loaded. A value of @code{like-original} specifies to compile |
437 the advice if the original definition of the advised function is | 437 the advice if the original definition of the advised function is |
438 compiled or a built-in function. | 438 compiled or a built-in function. |