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

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

Re: Temporary changing the behavior of a function


From: Stefan Monnier
Subject: Re: Temporary changing the behavior of a function
Date: Fri, 06 Nov 2015 08:03:47 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> Now I want to call `foo' in the Mafia-mode;-), i.e., it should ask no
> further questions.  What do I do?  AFAIU, `cl-flet' won't help, since it
> is lexical.  The best I can think of is to temporarily advice `bar' with
> :override - but then, instead of a `let'-like, local construct, I have
> to explicitly add and then remove the advice, right?

   (defvar my-bar-is-silent nil)
   (defun my-bar-silencer (orig &rest args)
     (if my-bar-is-silent <dosomethinggrommit> (apply orig args)))
   (advice-add 'bar :around #'my-bar-silencer)

and then

   ... (let ((my-bar-is-silent t))
         (foo ...))


-- Stefan




reply via email to

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