help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to shadow a function temporarily? (flet and cl-flet)


From: Alex Kost
Subject: How to shadow a function temporarily? (flet and cl-flet)
Date: Sun, 26 Jan 2014 18:11:11 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hello, I have 2 questions.

1. The main question is: how can I override a function with another
compatible function (with the same args) temporarily?

I want something like this:

(let-shadow ((+ '-))
  (+ 3 2))  ; should return 1, not 5

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).

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?

Attachment: binIE1OW64fA1.bin
Description: application/emacs-lisp

-- 
Alex Kost

reply via email to

[Prev in Thread] Current Thread [Next in Thread]