[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Last use of defadvice in Emacs
From: |
T.V Raman |
Subject: |
Re: Last use of defadvice in Emacs |
Date: |
Fri, 08 Apr 2022 07:21:07 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
Relevant pieces retained alongside responses:
>> 2. Re ad-return-value -- I've almost never had to explicitly set
>> ad-return-value -- in around and after advice, I have always
>> returned ad-return-value and have never hit issues --- perhaps
>> because I've always wrappered my advice body in a let form --
This has never bitten emacspeak because I always leave the return value
>> unmolested, and for safely always make sure that ad-return-value
>> is the last form in the advice body so that functions or code that
>> runs after the advice doesn't break because the original
>> function's return value got dropped along the way
>> not sure. What kind of breakages happen when returning
>> ad-return-value vs explicitly setting ad-return-value at the end
>> of the advice body?
>
> You typically need to set it when you want to do:
>
> (defadvice some-function (around my-advice activate)
> (if (bla bla)
> (cons 1 ad-do-it)
> (do something else)
> (and return some value)))
>
> which needs to be something like:
>
> (defadvice some-function (around my-advice activate)
> (if (bla bla)
> (progn ad-do-it
> (push 1 ad-return-value))
> (do something else)
> (setq ad-return-value (and return some value))))
>
>> 3. I've avoided the complexity around preactivation vs
>> activation etc by always saying (... pre act comp) in all my
Avoid complexity here == "my little brain doesn't have to worry about
it" --- all the calls to defadvice in emacspeak say "pre act comp"
which means if it needs changing, I can change them all with a single
line of perl or sed magic.
>> advice forms
>
> Not sure in which sense this "avoided the complexity".
> And most people reading your code won't know what it means, I'm afraid.
>
>
> Stefan
>
>
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
?7?4 Id: kg:/m/0285kf1 ?0?8
- Re: Last use of defadvice in Emacs, (continued)
- Re: Last use of defadvice in Emacs, Richard Stallman, 2022/04/05
- Re: Last use of defadvice in Emacs, Alan Mackenzie, 2022/04/06
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/06
- Re: Last use of defadvice in Emacs, T.V Raman, 2022/04/06
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/06
- Re: Last use of defadvice in Emacs, Eli Zaretskii, 2022/04/07
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/07
- Re: Last use of defadvice in Emacs, T.V Raman, 2022/04/07
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/07
- Re: Last use of defadvice in Emacs,
T.V Raman <=
- Re: Last use of defadvice in Emacs, Eli Zaretskii, 2022/04/08
- Re: Last use of defadvice in Emacs, Alan Mackenzie, 2022/04/07
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/07
- Re: Last use of defadvice in Emacs, Alan Mackenzie, 2022/04/08
- Re: Last use of defadvice in Emacs, Stefan Monnier, 2022/04/08
- Re: Last use of defadvice in Emacs, Alan Mackenzie, 2022/04/08