diff options
| author | Richard M. Stallman | 2005-08-09 11:59:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-08-09 11:59:22 +0000 |
| commit | 0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0 (patch) | |
| tree | c102680f1cb2430f3a8dc2a320d40815834bae9f | |
| parent | 4026bd74b2bf3bb422ff1c8525987f195dd63724 (diff) | |
| download | emacs-0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0.tar.gz emacs-0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0.zip | |
(Advising Functions): Explain when to use advice and when to use a hook.
| -rw-r--r-- | lispref/advice.texi | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lispref/advice.texi b/lispref/advice.texi index 2006474fc61..e741300b91d 100644 --- a/lispref/advice.texi +++ b/lispref/advice.texi | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | @cindex advising functions | 8 | @cindex advising functions |
| 9 | 9 | ||
| 10 | The @dfn{advice} feature lets you add to the existing definition of | 10 | The @dfn{advice} feature lets you add to the existing definition of |
| 11 | a function, by @dfn{advising the function}. This is a clean method | 11 | a function, by @dfn{advising the function}. This is a cleaner method |
| 12 | for a library to customize functions defined within 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 | ||
| @@ -23,8 +23,20 @@ are not the same thing. | |||
| 23 | 23 | ||
| 24 | @strong{Usage Note:} Advice is useful for altering the behavior of | 24 | @strong{Usage Note:} Advice is useful for altering the behavior of |
| 25 | existing calls to an existing function. If you want the new behavior | 25 | existing calls to an existing function. If you want the new behavior |
| 26 | for new calls, or for key bindings, it is cleaner to define a new | 26 | for new calls, or for key bindings, you should define a new function |
| 27 | function (or a new command) which uses the existing function. | 27 | (or a new command) which uses the existing function. |
| 28 | |||
| 29 | @strong{Usage note:} Advising a function can cause confusion in | ||
| 30 | debugging, since people who debug calls to the original function may | ||
| 31 | not notice that it has been modified with advice. Therefore, if you | ||
| 32 | have the possibility to change the code of that function (or ask | ||
| 33 | someone to do so) to run a hook, please solve the problem that way. | ||
| 34 | Advice should be reserved for the cases where you cannot get the | ||
| 35 | function changed. | ||
| 36 | |||
| 37 | In particular, this means that a file in Emacs should not put advice | ||
| 38 | on a function in Emacs. There are currently a few exceptions to this | ||
| 39 | convention, but we aim to correct them. | ||
| 28 | 40 | ||
| 29 | @menu | 41 | @menu |
| 30 | * Simple Advice:: A simple example to explain the basics of advice. | 42 | * Simple Advice:: A simple example to explain the basics of advice. |