From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daan Ro Newsgroups: gmane.emacs.bugs Subject: bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lambda) advices (old Emacs) Date: Tue, 13 Dec 2022 22:02:51 +0700 Message-ID: References: <93f01864-6cdf-2d04-d08c-d0b52dc7773f@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000009cb77c05efb6ea83" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26302"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59820@debbugs.gnu.org, Stefan Kangas To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 13 16:04:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p56pR-0006g9-F6 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Dec 2022 16:04:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p56p9-00058k-6m; Tue, 13 Dec 2022 10:04:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p56p8-00057u-LT for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 10:04:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p56p8-0007vp-DA for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 10:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p56p7-0004xX-U4 for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 10:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daan Ro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Dec 2022 15:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59820-submit@debbugs.gnu.org id=B59820.167094379019037 (code B ref 59820); Tue, 13 Dec 2022 15:04:01 +0000 Original-Received: (at 59820) by debbugs.gnu.org; 13 Dec 2022 15:03:10 +0000 Original-Received: from localhost ([127.0.0.1]:60951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p56oI-0004wz-Ch for submit@debbugs.gnu.org; Tue, 13 Dec 2022 10:03:10 -0500 Original-Received: from mail-lf1-f54.google.com ([209.85.167.54]:37492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p56oH-0004wp-2t for 59820@debbugs.gnu.org; Tue, 13 Dec 2022 10:03:09 -0500 Original-Received: by mail-lf1-f54.google.com with SMTP id 1so5367000lfz.4 for <59820@debbugs.gnu.org>; Tue, 13 Dec 2022 07:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hVZ9yQ7JsvMSp3kCgXDRwge5Ql2mS+CBUMbQEKujHtM=; b=Xw7TABMBuzDZgrF8lKMVBypZarkCViyz0LMxla/HmdWZVzb7WY2oCPvx/spqwznUX9 bexYZ6g/YCg2pt1CA37+Wi0lBghneX1Vg6UYKRyk/Tz6qaAm1zYU2CYyRj2Xue/2Z6RK Vxs4tpfzhL7Svq0RjzzIB4nPCMlLJXqMqLTOGW4wClRTk8JYkMYDyzro12SGX+MHi/ZG 7ou9Jdg4J3/Vh8XEgmG7hbvKdS6kNMmBage3Ev62qafwHUfee01m1uEbZ/3NL3uO2xgx 2q0A3KfQHoGTkIBh0fdc4SVYg8S5obriFKwXz6A3WRXLVq5QEUQE/LWGAZ6DkcqVOJcH MJIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hVZ9yQ7JsvMSp3kCgXDRwge5Ql2mS+CBUMbQEKujHtM=; b=Hnh6ro95WVbDS2JMrOw+vwQNmuRbE7+f/GeV1QAuuHqvtxPU1csffMf8JMmZ0+nt72 rfhFTZEwWQm1dDrmLrJ9dyb2zBSwEDvj7Y7wCRzhS0RuMwzMElTm9JktfyMNOHPKn9Zf OP6PPiYcc2qm9lcMUfyR4uaYxya5157Bo8b6fDLaEg966Nm+im5kZ4MP746M8KFtTry3 VClqEc4sgRLWWg6FWu2OQvEsGjCExIYDIb8dKZ2nEScA6SPMSBph5wQUdrqNmXrimPaa rNhcfmqrF408lDMoh0vopXl5Wg3OjZ8bE9Xws2bO0WUGOysyYMFQNRk7b+DWbtJ/yMSp WIsA== X-Gm-Message-State: ANoB5pmR0WplX+8NECBphssNLXO9KYnj9YOw6KsKDLzh+UybWaQK7Gl+ o8CsFC0ZLzlzk57kK/C73jaA2bK2LXgUHl44Gng= X-Google-Smtp-Source: AA0mqf4j1uHPms18SlP0jabFYxkBjxp5JuPC3ZLE/u/KFH3FwRt+n7CeeBS5RYGd1F51UEmgLcKd5ltnVMYORAR29k8= X-Received: by 2002:a05:6512:3762:b0:4ac:5faa:654d with SMTP id z2-20020a056512376200b004ac5faa654dmr30030159lft.684.1670943782764; Tue, 13 Dec 2022 07:03:02 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250847 Archived-At: --0000000000009cb77c05efb6ea83 Content-Type: multipart/alternative; boundary="0000000000009cb77a05efb6ea81" --0000000000009cb77a05efb6ea81 Content-Type: text/plain; charset="UTF-8" Use `warn` instead of `message`. On Tue, Dec 13, 2022 at 9:59 PM daanturo wrote: > > 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. > -- Daanturo. --0000000000009cb77a05efb6ea81 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Use `warn` instead of `message`.

On Tue, Dec 13, 2022= at 9:59 PM daanturo <daanturo@gma= il.com> wrote:
> 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 nadv= ice.el's
>> advice-add the ability to handle anonymous advices.
> [...]
>> +(defun advice--ensure-symbol (func)
>> +=C2=A0 (if (symbolp func)
>> +=C2=A0 =C2=A0 =C2=A0 func
>> +=C2=A0 =C2=A0 (let* ((sym (intern (format "%S" func))))=
>> +=C2=A0 =C2=A0 =C2=A0 (unless (fboundp sym)
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (defalias sym func))
>> +=C2=A0 =C2=A0 =C2=A0 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 muc= h
> time, ...).
>
> IOW I'd rather align the "real nadvice.el" with the one = in GNU ELPA than
> the other way around in this respect.
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Stefan
>
--
Daanturo.


--
Daanturo.
--0000000000009cb77a05efb6ea81-- --0000000000009cb77c05efb6ea83 Content-Type: text/x-patch; charset="US-ASCII"; name="0002-nadvice-nadvice.el-warn-against-non-symbol-FUNCTIONs.patch" Content-Disposition: attachment; filename="0002-nadvice-nadvice.el-warn-against-non-symbol-FUNCTIONs.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lbmcr5d20 RnJvbSBmMzBhMWY2ZDgxNWEwMzhkZGU1MWVhMDkwODllOWFhMjE1NWM4YzYyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEYWFudHVybyA8ZGFhbnR1cm9AZ21haWwuY29tPgpEYXRlOiBU dWUsIDEzIERlYyAyMDIyIDIxOjI4OjAzICswNzAwClN1YmplY3Q6IFtQQVRDSF0gKiBuYWR2aWNl L25hZHZpY2UuZWw6IHdhcm4gYWdhaW5zdCBub24tc3ltYm9sIEZVTkNUSU9OcwoKLS0tCiBuYWR2 aWNlLmVsIHwgMiArKwogMSBmaWxlIGNoYW5nZWQsIDIgaW5zZXJ0aW9ucygrKQoKZGlmZiAtLWdp dCBhL25hZHZpY2UuZWwgYi9uYWR2aWNlLmVsCmluZGV4IDQ0M2E1ZDAuLmM2NjY2ZDAgMTAwNjQ0 Ci0tLSBhL25hZHZpY2UuZWwKKysrIGIvbmFkdmljZS5lbApAQCAtNTcsNiArNTcsOCBAQAogICAo aWYgKHN5bWJvbHAgZnVuYykKICAgICAgIGZ1bmMKICAgICAobGV0KiAoKHN5bSAoaW50ZXJuIChm b3JtYXQgIiVTIiBmdW5jKSkpKQorICAgICAgKHdhcm4gIlRoaXMgdmVyc2lvbiBvZiBuYWR2aWNl LmVsIHJlY29tbWVuZHMgdGhhdCBcCitGVU5DVElPTjogJVMgaXMgYSBuYW1lZCBzeW1ib2wgaW5z dGVhZC4iIGZ1bmMpCiAgICAgICAodW5sZXNzIChmYm91bmRwIHN5bSkKICAgICAgICAgKGRlZmFs aWFzIHN5bSBmdW5jKSkKICAgICAgIHN5bSkpKQotLSAKMi4zOS4wCgo= --0000000000009cb77c05efb6ea83--