From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#14293: 23.4; Unclarity in documentation: flet replaced by cl-flet of cl-letf in 24.3 and up. Date: Sat, 04 May 2013 15:50:24 -0400 Message-ID: References: <0174328B-6C51-4143-8FD7-DE02EB82E86D@nikolaus-demmel.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1367697084 30287 80.91.229.3 (4 May 2013 19:51:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 May 2013 19:51:24 +0000 (UTC) Cc: 14293-done@debbugs.gnu.org To: Nikolaus Demmel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 04 21:51:22 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UYiUL-0006wq-KK for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 May 2013 21:51:21 +0200 Original-Received: from localhost ([::1]:40785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYiUL-0005rj-9n for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 May 2013 15:51:21 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYiUH-0005re-Gz for bug-gnu-emacs@gnu.org; Sat, 04 May 2013 15:51:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYiUF-0005pX-KD for bug-gnu-emacs@gnu.org; Sat, 04 May 2013 15:51:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYiUF-0005pR-HZ for bug-gnu-emacs@gnu.org; Sat, 04 May 2013 15:51:15 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UYiV0-0000gx-CC for bug-gnu-emacs@gnu.org; Sat, 04 May 2013 15:52:02 -0400 Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 May 2013 19:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 14293 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 14293@debbugs.gnu.org, monnier@IRO.UMontreal.CA, nikolaus@nikolaus-demmel.de Original-Received: via spool by 14293-done@debbugs.gnu.org id=D14293.13676970752549 (code D ref 14293); Sat, 04 May 2013 19:52:01 +0000 Original-Received: (at 14293-done) by debbugs.gnu.org; 4 May 2013 19:51:15 +0000 Original-Received: from localhost ([127.0.0.1]:58198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UYiUF-0000f4-7s for submit@debbugs.gnu.org; Sat, 04 May 2013 15:51:15 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:49005) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UYiUD-0000ev-9j for 14293-done@debbugs.gnu.org; Sat, 04 May 2013 15:51:14 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r44JoOp0022551; Sat, 4 May 2013 15:50:25 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 1DD6DAE1B2; Sat, 4 May 2013 15:50:24 -0400 (EDT) In-Reply-To: <0174328B-6C51-4143-8FD7-DE02EB82E86D@nikolaus-demmel.de> (Nikolaus Demmel's message of "Sat, 27 Apr 2013 13:37:46 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4569=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4569> : streams <954035> : uri <1411555> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73963 Archived-At: > that using defadvice might be more appropriate. Maybe the information > about how to precisely replace flet (i.e. same call if using cl-flet, > different syntax if dynamic binding is desired using cl-letf, with an > hint that defadvice might be better) could be included somewhere in the > docs, maybe in [2]? Thanks. I installed the patch below. Stefan === modified file 'doc/misc/cl.texi' --- doc/misc/cl.texi 2013-02-20 02:07:07 +0000 +++ doc/misc/cl.texi 2013-05-04 19:46:20 +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, +@code{cl-flet} 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: + +@example +(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)))) +@end 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. +handling. Attempts to redefine such functions using @code{flet}, @code{letf}, +or an advice will fail when byte-compiled. @c Or cl-flet. @c In such cases, use @code{labels} instead. @end defmac