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

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

bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lam


From: daanturo
Subject: bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lambda) advices (old Emacs)
Date: Tue, 13 Dec 2022 21:59:23 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

> I usually recommend to use named
> functions for advice anyway

How about we still allow but warn against such problematic usage?


On 13/12/2022 20:50, Stefan Monnier wrote:
>> This patch provides the ELPA version (for Emacs < 24.4) of nadvice.el's
>> advice-add the ability to handle anonymous advices.
> [...]
>> +(defun advice--ensure-symbol (func)
>> +  (if (symbolp func)
>> +      func
>> +    (let* ((sym (intern (format "%S" func))))
>> +      (unless (fboundp sym)
>> +        (defalias sym func))
>> +      sym)))
> I'm not a big fan of this approach, and I usually recommend to use named
> functions for advice anyway (avoids all kinds of problems like the
> `advice-remove` failing to remove, or the equality test taking too much
> time, ...).
>
> IOW I'd rather align the "real nadvice.el" with the one in GNU ELPA than
> the other way around in this respect.
>
>
>         Stefan
>
-- 
Daanturo.

Attachment: 0002-nadvice-nadvice.el-warn-against-non-symbol-FUNCTIONs.patch
Description: Text Data


reply via email to

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