all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "T.V Raman" <raman@google.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: eliz@gnu.org,  acm@muc.de,  bug-cc-mode@gnu.org,  emacs-devel@gnu.org
Subject: Re: Last use of defadvice in Emacs
Date: Fri, 08 Apr 2022 07:21:07 -0700	[thread overview]
Message-ID: <p91k0bzvep8.fsf@google.com> (raw)
In-Reply-To: <jwvpmlsnwn1.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 07 Apr 2022 22:34:45 -0400")

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 2091 bytes --]

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



  reply	other threads:[~2022-04-08 14:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 19:49 Last use of defadvice in Emacs Stefan Monnier
2022-04-04 20:08 ` T.V Raman
2022-04-04 20:38   ` Stefan Monnier via CC-Mode-help
2022-04-04 20:48     ` T.V Raman
2022-04-05  4:28 ` Richard Stallman
2022-04-06 18:52 ` Alan Mackenzie
2022-04-06 21:08   ` Stefan Monnier via CC-Mode-help
2022-04-07  1:51     ` T.V Raman
2022-04-07  2:49       ` Stefan Monnier via CC-Mode-help
2022-04-07  6:14         ` Eli Zaretskii
2022-04-07 21:59           ` Stefan Monnier via CC-Mode-help
2022-04-08  1:49             ` T.V Raman
2022-04-08  2:34               ` Stefan Monnier via CC-Mode-help
2022-04-08 14:21                 ` T.V Raman [this message]
2022-04-08  6:00             ` Eli Zaretskii
2022-04-07 18:18     ` Alan Mackenzie
2022-04-07 18:37       ` Stefan Monnier
2022-04-08 17:10         ` Alan Mackenzie
2022-04-08 17:39           ` Stefan Monnier via CC-Mode-help
2022-04-08 18:06             ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=p91k0bzvep8.fsf@google.com \
    --to=raman@google.com \
    --cc=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.