From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How to shadow a function temporarily? (flet and cl-flet) Date: Sun, 26 Jan 2014 20:03:27 +0100 Organization: WMI UAM Message-ID: <20140126200327.410f58eb@aga-netbook> References: <87k3dm4yv4.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1390763199 28530 80.91.229.3 (26 Jan 2014 19:06:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Jan 2014 19:06:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 26 20:06:47 2014 Return-path: Envelope-to: geh-help-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 1W7V2c-0004XU-8T for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 20:06:46 +0100 Original-Received: from localhost ([::1]:55905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7V2b-0004QY-Q5 for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 14:06:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7UzZ-0000Po-22 for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:03:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7UzT-00029T-GE for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:03:36 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:42695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7UzT-00028I-93 for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:03:31 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 9109565563 for ; Sun, 26 Jan 2014 20:03:29 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ji6PsiBOxy5b for ; Sun, 26 Jan 2014 20:03:29 +0100 (CET) Original-Received: from aga-netbook (101-138.echostar.pl [213.156.101.138]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 5F69A65562 for ; Sun, 26 Jan 2014 20:03:29 +0100 (CET) In-Reply-To: <87k3dm4yv4.fsf@gmail.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.17; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95673 Archived-At: Dnia 2014-01-26, o godz. 18:11:11 Alex Kost napisa=C5=82(a): > Hello, I have 2 questions. >=20 > 1. The main question is: how can I override a function with another > compatible function (with the same args) temporarily? >=20 > I want something like this: >=20 > (let-shadow ((+ '-)) > (+ 3 2)) ; should return 1, not 5 >=20 > 2. If there is no such macro, I can use `flet' for my purposes, but it > is obsolete and `cl-flet' doesn't do what I need (see attached > example). >=20 > According to (info "(cl) Obsolete Macros"), `flet' makes a dynamic > binding (unlike `cl-flet'). So the second question is: how can I > avoid using obsolete `flet` if I need a dynamic binding? Am I right that this could be done with advising? HTH, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University