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

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

Re: flet, cl-flet, cl-letf in 24.3


From: Stefan Monnier
Subject: Re: flet, cl-flet, cl-letf in 24.3
Date: Mon, 22 Apr 2013 09:32:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> as reported here [5], this documentation does not really tell me what to do
> if I want to keep relying on the dynamic scoping of flet.  A brief google
> search [6] leads me to believe that

>     (cl-letf (((symbol-function 'foo) #'(lambda (...) ...))) ...) 

> is the suggested solution,

That's the case.

> Does that always have dynamic scope?

How could it not?

> however I wanted to make sure that is the case.

Even better in most cases is:

     (defvar my-enable-foo-advice nil)
     (defadvice foo (...)
       (if my-enable-foo-advice ... ...))

and then replace (flet ((foo ...)) ...)
with (let ((my-enable-foo-advice t)) ...)


        Stefan




reply via email to

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