aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-05-04 15:49:23 -0400
committerStefan Monnier2013-05-04 15:49:23 -0400
commit0a6313f7e3062a1c4ed2b32b68122484e847dc0f (patch)
tree015383336887c0c24595cd45085979cbf23f6bee
parent998768afd27ecfc8bea7549a84208e0fe204d33b (diff)
downloademacs-0a6313f7e3062a1c4ed2b32b68122484e847dc0f.tar.gz
emacs-0a6313f7e3062a1c4ed2b32b68122484e847dc0f.zip
* doc/misc/cl.texi (Obsolete Macros): Describe replacements for `flet'.
Fixes: debbugs:14293
-rw-r--r--doc/misc/ChangeLog5
-rw-r--r--doc/misc/cl.texi23
2 files changed, 25 insertions, 3 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 5e9840a86b7..74b08c04714 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,8 @@
12013-05-04 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * cl.texi (Obsolete Macros): Describe replacements for `flet'
4 (bug#14293).
5
12013-04-16 Michael Albinus <michael.albinus@gmx.de> 62013-04-16 Michael Albinus <michael.albinus@gmx.de>
2 7
3 * tramp.texi (Frequently Asked Questions): Precise, how to define 8 * tramp.texi (Frequently Asked Questions): Precise, how to define
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 83df411cb23..90f8a258d23 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -4850,10 +4850,27 @@ generated directly inside Emacs will not be caught since they make
4850direct C-language calls to the message routines rather than going 4850direct C-language calls to the message routines rather than going
4851through the Lisp @code{message} function. 4851through the Lisp @code{message} function.
4852 4852
4853For those cases where the dynamic scoping of @code{flet} is desired,
4854@code{cl-flet} is clearly not a substitute. The most direct replacement would
4855be instead to use @code{cl-letf} to temporarily rebind @code{(symbol-function
4856'@var{fun})}. But in most cases, a better substitute is to use an advice, such
4857as:
4858
4859@example
4860(defvar my-fun-advice-enable nil)
4861(add-advice '@var{fun} :around
4862 (lambda (orig &rest args)
4863 (if my-fun-advice-enable (do-something)
4864 (apply orig args))))
4865@end example
4866
4867so that you can then replace the @code{flet} with a simple dynamically scoped
4868binding of @code{my-fun-advice-enable}.
4869
4853@c Bug#411. 4870@c Bug#411.
4854Note that many primitives (e.g., @code{+}) have special byte-compile 4871Note that many primitives (e.g., @code{+}) have special byte-compile handling.
4855handling. Attempts to redefine such functions using @code{flet} will 4872Attempts to redefine such functions using @code{flet}, @code{cl-letf}, or an
4856fail if byte-compiled. 4873advice will fail when byte-compiled.
4857@c Or cl-flet. 4874@c Or cl-flet.
4858@c In such cases, use @code{labels} instead. 4875@c In such cases, use @code{labels} instead.
4859@end defmac 4876@end defmac