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:25:21 +0400 Message-ID: <874n4q4kbi.fsf@gmail.com> References: <87d2jed86s.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1390764475 10276 80.91.229.3 (26 Jan 2014 19:27:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Jan 2014 19:27:55 +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:28:02 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 1W7VNC-0004b6-75 for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 20:28:02 +0100 Original-Received: from localhost ([::1]:55994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VNB-0005xh-Oc for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 14:28:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VKo-0002ts-CM for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:25:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7VKf-0000Hf-5R for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:25:33 -0500 Original-Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:51169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7VKe-0000H9-SO for help-gnu-emacs@gnu.org; Sun, 26 Jan 2014 14:25:25 -0500 Original-Received: by mail-la0-f54.google.com with SMTP id y1so3984413lam.27 for ; Sun, 26 Jan 2014 11:25:23 -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; bh=Aglei7kwmwz70ElhGcTzW5YJaqg1uBDePxNKPjeqCgU=; b=aYGxUFQnnRwDl68XWCoWShUgSwI0ntBr7HFdcyfTtDrVt3cP62zJkqdQ6oSgqdxM1O G9BfAM0MuwEGr+R6uWEc6ljE9gc/77P0hXkFuFF/URH1tKIwsXJGjsabkfSe2LPHXCeW f0iRkj61EGZJsBmmSX4qz3AzdSw5db+/v2o/AtDHO69W1lYPnYi2KGf8cKN1lgyqNZ9K bpuSMGTuHY1QL+Q4B1nid7gpDMDvfrWw8fDnVf4MLVsvHpPGSmRH1vG7mU7VZ1I31ppH IZ5TVDh8GxtP7ZpKYPC8IC1hebdI89+yNJH3NpP4av8/D+g/kqt0g5e1II9CdC/dEEil SAHg== X-Received: by 10.112.236.3 with SMTP id uq3mr14582381lbc.14.1390764323373; Sun, 26 Jan 2014 11:25:23 -0800 (PST) Original-Received: from leviafan (128-70-204-126.broadband.corbina.ru. [128.70.204.126]) by mx.google.com with ESMTPSA id n13sm9364734lbl.17.2014.01.26.11.25.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jan 2014 11:25:22 -0800 (PST) In-Reply-To: <87d2jed86s.fsf@nl106-137-194.student.uu.se> (Emanuel Berg's message of "Sun, 26 Jan 2014 17:22:10 +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:c03::236 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:95675 Archived-At: Emanuel Berg (2014-01-26 20:22 +0400) wrote: > Alex Kost writes: > >> 1. The main question is: how can I override a >> function with another compatible function (with the >> same args) temporarily? > > Why do you want to do that? It might help if you tell > us, because there might be other (better) ways to do > what you want. I have written why I need it in a response to Stephan's letter. > I don't know of an interface to do that, if you want to > do it habitually, but on a per function-basis, you can > use fset to redefine (set) the functions of symbols: > > (fset '+ (lambda (&rest args) (apply '- args))) > > And it is "temporary" in the sense that it works as > long as you don't reset it. But if you go around > mucking about like that, I don't know what will break > first - Emacs or your mind. So I don't think you have > to worry about the "temporary" aspect :) Thank you, I know about `fset', I can even do (fset '+ '-), I just wanted a `let'-like form to be sure that I will not stay with `-' instead of `+' in a case of error or quit.