[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to shadow a function temporarily? (flet and cl-flet)
From: |
Alex Kost |
Subject: |
Re: How to shadow a function temporarily? (flet and cl-flet) |
Date: |
Sun, 26 Jan 2014 23:25:21 +0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Emanuel Berg (2014-01-26 20:22 +0400) wrote:
> Alex Kost <alezost@gmail.com> 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.
Re: How to shadow a function temporarily? (flet and cl-flet), Marcin Borkowski, 2014/01/26