From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: How to shadow a function temporarily? (flet and cl-flet) Date: Sun, 26 Jan 2014 23:31:04 +0400 Message-ID: <87zjmi35hj.fsf@gmail.com> References: <87k3dm4yv4.fsf@gmail.com> <20140126200327.410f58eb@aga-netbook> 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 1390764990 15170 80.91.229.3 (26 Jan 2014 19:36:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Jan 2014 19:36:30 +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:36:36 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 1W7VVT-00080W-A4 for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 20:36:35 +0100 Original-Received: from localhost ([::1]:56085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VVS-0002Ib-Sj for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 14:36:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VQK-0003Y0-38 for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:31:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7VQB-0002BZ-Mc for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:31:16 -0500 Original-Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]:35299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VQB-0002BU-CO for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:31:07 -0500 Original-Received: by mail-lb0-f181.google.com with SMTP id z5so3821258lbh.40 for ; Sun, 26 Jan 2014 11:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=bOWC/rS6KB9vw/jBQtwqlx5JcxjpEYZeSkDhYQfpPbE=; b=iUGjiCjAzdqgI9YiFNJNmteixcr/kAObUJsgbXj6Uzw8Kb6b2ZERnvbtQrBmRP/oFw /7BRh7kWVD1GPNEnvMzcmhI1uw20XgFxol6UFBcPaV707qCyOdgu5v3A9kkJ0i8Aerm/ MPYNP2d6bGtprcB3Qv7Cr3OJTTBjJzKkrHKUVNuQYVbz8KgCZa9sMMST2ze9CSagn322 nDD19dGH9J9HLTJom4/1XxJI6OxTcZNa7wDsVogpXbs/ClqL3SK85OGI9O0B/2Lcj6RP odulzxCP9/md3zc20FIoyrB4am4FES0Sdiiof6fvCnGOgpiKsKYyipkMqumOOd76ECZY Cdig== X-Received: by 10.152.170.232 with SMTP id ap8mr183lac.40.1390764666188; Sun, 26 Jan 2014 11:31:06 -0800 (PST) Original-Received: from leviafan (128-70-204-126.broadband.corbina.ru. [128.70.204.126]) by mx.google.com with ESMTPSA id a8sm13248247lae.5.2014.01.26.11.31.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jan 2014 11:31:05 -0800 (PST) In-Reply-To: <20140126200327.410f58eb@aga-netbook> (Marcin Borkowski's message of "Sun, 26 Jan 2014 20:03:27 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::235 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:95676 Archived-At: Marcin Borkowski (2014-01-26 23:03 +0400) wrote: > 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? Thanks, but i don't want to make an advice mainly because i need it for emacs package, not for my own config.