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

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

Re: replacing a function with another one


From: lee
Subject: Re: replacing a function with another one
Date: Mon, 10 Mar 2014 14:45:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> lee <address@hidden> writes:
>>
>> (defadvice hi-lock-set-file-patterns (after
>> lsl-hi-lock-set-file-patterns-advice activate)
>>   (setq hi-lock-interactive-patterns (ad-get-arg 0)))
>
>> How would I do the same with add-advice (or whatever is appropriate)?
>
> (advice-add
>  'hi-lock-set-file-patterns :after
>  (lambda (patterns)
>    (setq hi-lock-interactive-patterns patterns)))
>
> You can also give the piece of advice a name like in defadvice:

I think I start to understand :)  You are creating an anonymous function
and attach it to hi-lock-set-file-patterns so it runs after it.

What are the equivalents of ad-deactivate and ad-activate with
advice-add?  I only found advice-add and advice-remove.  Is it possible
that an advice adds and removes itself instead of activating and
deactivating itself?


-- 
Knowledge is volatile and fluid.  Software is power.



reply via email to

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