From: Marcin Borkowski <mbork@mbork.pl>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: How to get advised function name form inside of the advice
Date: Fri, 04 Mar 2016 19:32:23 +0100 [thread overview]
Message-ID: <87oaaum6vc.fsf@mbork.pl> (raw)
In-Reply-To: <878u1y89my.fsf@gmail.com>
On 2016-03-04, at 17:56, Vitalie Spinu <spinuvit@gmail.com> wrote:
>>> On Fri, Mar 04 2016 15:16, Marcin Borkowski wrote:
>
>> On 2016-03-04, at 14:36, Vitalie Spinu <spinuvit@gmail.com> wrote:
>
>>> Hi,
>>>
>>> How to retrieve the name of the original function from the inside of "new"
>>> advice? I need to condition-case a function and show a meaningful error message
>>> with function name instead of an error.
>
>> It seems that you can't do that (and for good reasons). See here:
>> https://lists.gnu.org/archive/html/help-gnu-emacs/2016-02/msg00218.html
>
>
> Hm, I thought so. Thanks.
>
> What are those good reasons though? I don't see any reasons given in that
> thread.
Because they are not given there. The main reason is: this is Lisp,
a function can have one name, a few names (neither of which is "main" or
"canonical"), or no name.
> I think my use case is a good reason to have such a feature. Otherwise one would
> need a macro to define separate advice function per advice or pass a closure as
> an advice. Both ways are overkill for such a basic requirement.
This is exactly what I have done. See here:
https://lists.gnu.org/archive/html/help-gnu-emacs/2016-02/msg00219.html
for my approach (including a stupid mistake of using `make-symbol'
instead if `intern', promptly corrected by Michael H.)
> Vitalie
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
next prev parent reply other threads:[~2016-03-04 18:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 13:36 How to get advised function name form inside of the advice Vitalie Spinu
2016-03-04 14:16 ` Marcin Borkowski
2016-03-04 16:56 ` Vitalie Spinu
2016-03-04 18:30 ` Michael Heerdegen
2016-03-04 18:32 ` Marcin Borkowski [this message]
2016-03-08 4:22 ` Stefan Monnier
2016-03-21 1:33 ` Vitalie Spinu
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=87oaaum6vc.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=emacs-devel@gnu.org \
--cc=spinuvit@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.