diff options
| author | Stefan Monnier | 2013-05-04 15:49:23 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-04 15:49:23 -0400 |
| commit | 0a6313f7e3062a1c4ed2b32b68122484e847dc0f (patch) | |
| tree | 015383336887c0c24595cd45085979cbf23f6bee | |
| parent | 998768afd27ecfc8bea7549a84208e0fe204d33b (diff) | |
| download | emacs-0a6313f7e3062a1c4ed2b32b68122484e847dc0f.tar.gz emacs-0a6313f7e3062a1c4ed2b32b68122484e847dc0f.zip | |
* doc/misc/cl.texi (Obsolete Macros): Describe replacements for `flet'.
Fixes: debbugs:14293
| -rw-r--r-- | doc/misc/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/misc/cl.texi | 23 |
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 @@ | |||
| 1 | 2013-05-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * cl.texi (Obsolete Macros): Describe replacements for `flet' | ||
| 4 | (bug#14293). | ||
| 5 | |||
| 1 | 2013-04-16 Michael Albinus <michael.albinus@gmx.de> | 6 | 2013-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 | |||
| 4850 | direct C-language calls to the message routines rather than going | 4850 | direct C-language calls to the message routines rather than going |
| 4851 | through the Lisp @code{message} function. | 4851 | through the Lisp @code{message} function. |
| 4852 | 4852 | ||
| 4853 | For 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 | ||
| 4855 | be 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 | ||
| 4857 | as: | ||
| 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 | |||
| 4867 | so that you can then replace the @code{flet} with a simple dynamically scoped | ||
| 4868 | binding of @code{my-fun-advice-enable}. | ||
| 4869 | |||
| 4853 | @c Bug#411. | 4870 | @c Bug#411. |
| 4854 | Note that many primitives (e.g., @code{+}) have special byte-compile | 4871 | Note that many primitives (e.g., @code{+}) have special byte-compile handling. |
| 4855 | handling. Attempts to redefine such functions using @code{flet} will | 4872 | Attempts to redefine such functions using @code{flet}, @code{cl-letf}, or an |
| 4856 | fail if byte-compiled. | 4873 | advice 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 |