From: Daan Ro <daanturo@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 59820@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>
Subject: bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lambda) advices (old Emacs)
Date: Tue, 13 Dec 2022 22:02:51 +0700 [thread overview]
Message-ID: <CAGNN0nDNa2o4ngakELSvd_2w5NFzsyf=wH-W280T3NK9v_QdLg@mail.gmail.com> (raw)
In-Reply-To: <a157dccd-eb0f-bd28-55f8-55ae6a6e336f@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1091 bytes --]
Use `warn` instead of `message`.
On Tue, Dec 13, 2022 at 9:59 PM daanturo <daanturo@gmail.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 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.
[-- Attachment #1.2: Type: text/html, Size: 1707 bytes --]
[-- Attachment #2: 0002-nadvice-nadvice.el-warn-against-non-symbol-FUNCTIONs.patch --]
[-- Type: text/x-patch, Size: 668 bytes --]
From f30a1f6d815a038dde51ea09089e9aa2155c8c62 Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Tue, 13 Dec 2022 21:28:03 +0700
Subject: [PATCH] * nadvice/nadvice.el: warn against non-symbol FUNCTIONs
---
nadvice.el | 2 ++
1 file changed, 2 insertions(+)
diff --git a/nadvice.el b/nadvice.el
index 443a5d0..c6666d0 100644
--- a/nadvice.el
+++ b/nadvice.el
@@ -57,6 +57,8 @@
(if (symbolp func)
func
(let* ((sym (intern (format "%S" func))))
+ (warn "This version of nadvice.el recommends that \
+FUNCTION: %S is a named symbol instead." func)
(unless (fboundp sym)
(defalias sym func))
sym)))
--
2.39.0
next prev parent reply other threads:[~2022-12-13 15:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-04 17:14 bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lambda) advices (old Emacs) daanturo
2022-12-13 1:04 ` Stefan Kangas
2022-12-13 13:50 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 14:59 ` daanturo
2022-12-13 15:02 ` Daan Ro [this message]
2023-10-09 9:45 ` Stefan Kangas
2023-10-09 22:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-10 10:44 ` Stefan Kangas
2023-10-11 6:04 ` Daan Ro
2023-10-11 6:50 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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='CAGNN0nDNa2o4ngakELSvd_2w5NFzsyf=wH-W280T3NK9v_QdLg@mail.gmail.com' \
--to=daanturo@gmail.com \
--cc=59820@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=stefankangas@gmail.com \
/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.