emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112450: * doc/misc/cl.texi (Obsolete


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112450: * doc/misc/cl.texi (Obsolete Macros): Describe replacements for `flet'.
Date: Sat, 04 May 2013 15:49:23 -0400
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112450
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14293
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sat 2013-05-04 15:49:23 -0400
message:
  * doc/misc/cl.texi (Obsolete Macros): Describe replacements for `flet'.
modified:
  doc/misc/ChangeLog
  doc/misc/cl.texi
=== modified file 'doc/misc/ChangeLog'
--- a/doc/misc/ChangeLog        2013-04-16 08:11:56 +0000
+++ b/doc/misc/ChangeLog        2013-05-04 19:49:23 +0000
@@ -1,3 +1,8 @@
+2013-05-04  Stefan Monnier  <address@hidden>
+
+       * cl.texi (Obsolete Macros): Describe replacements for `flet'
+       (bug#14293).
+
 2013-04-16  Michael Albinus  <address@hidden>
 
        * tramp.texi (Frequently Asked Questions): Precise, how to define

=== modified file 'doc/misc/cl.texi'
--- a/doc/misc/cl.texi  2013-02-20 02:07:07 +0000
+++ b/doc/misc/cl.texi  2013-05-04 19:49:23 +0000
@@ -4850,10 +4850,27 @@
 direct C-language calls to the message routines rather than going
 through the Lisp @code{message} function.
 
+For those cases where the dynamic scoping of @code{flet} is desired,
address@hidden is clearly not a substitute.  The most direct replacement would
+be instead to use @code{cl-letf} to temporarily rebind @code{(symbol-function
+'@var{fun})}.  But in most cases, a better substitute is to use an advice, such
+as:
+
address@hidden
+(defvar my-fun-advice-enable nil)
+(add-advice '@var{fun} :around
+            (lambda (orig &rest args)
+              (if my-fun-advice-enable (do-something)
+                (apply orig args))))
address@hidden example
+
+so that you can then replace the @code{flet} with a simple dynamically scoped
+binding of @code{my-fun-advice-enable}.
+
 @c Bug#411.
-Note that many primitives (e.g., @code{+}) have special byte-compile
-handling.  Attempts to redefine such functions using @code{flet} will
-fail if byte-compiled.
+Note that many primitives (e.g., @code{+}) have special byte-compile handling.
+Attempts to redefine such functions using @code{flet}, @code{cl-letf}, or an
+advice will fail when byte-compiled.
 @c Or cl-flet.
 @c In such cases, use @code{labels} instead.
 @end defmac


reply via email to

[Prev in Thread] Current Thread [Next in Thread]