aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-08-09 11:59:22 +0000
committerRichard M. Stallman2005-08-09 11:59:22 +0000
commit0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0 (patch)
treec102680f1cb2430f3a8dc2a320d40815834bae9f
parent4026bd74b2bf3bb422ff1c8525987f195dd63724 (diff)
downloademacs-0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0.tar.gz
emacs-0e15f9b48da2d0b6c2a1ddde8d616ce537b19aa0.zip
(Advising Functions): Explain when to use advice and when to use a hook.
-rw-r--r--lispref/advice.texi18
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
11a function, by @dfn{advising the function}. This is a clean method 11a function, by @dfn{advising the function}. This is a cleaner method
12for a library to customize functions defined within Emacs---cleaner 12for a library to customize functions defined within Emacs---cleaner
13than redefining the whole function. 13than 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
25existing calls to an existing function. If you want the new behavior 25existing calls to an existing function. If you want the new behavior
26for new calls, or for key bindings, it is cleaner to define a new 26for new calls, or for key bindings, you should define a new function
27function (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
30debugging, since people who debug calls to the original function may
31not notice that it has been modified with advice. Therefore, if you
32have the possibility to change the code of that function (or ask
33someone to do so) to run a hook, please solve the problem that way.
34Advice should be reserved for the cases where you cannot get the
35function changed.
36
37 In particular, this means that a file in Emacs should not put advice
38on a function in Emacs. There are currently a few exceptions to this
39convention, 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.