From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.devel Subject: Re: How to get advised function name form inside of the advice Date: Fri, 04 Mar 2016 19:32:23 +0100 Message-ID: <87oaaum6vc.fsf@mbork.pl> References: <87lh5ytlfa.fsf@gmail.com> <87ziuemip7.fsf@mbork.pl> <878u1y89my.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1457116368 15521 80.91.229.3 (4 Mar 2016 18:32:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Mar 2016 18:32:48 +0000 (UTC) Cc: emacs-devel@gnu.org To: Vitalie Spinu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 04 19:32:39 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1abuWl-0006EX-Js for ged-emacs-devel@m.gmane.org; Fri, 04 Mar 2016 19:32:39 +0100 Original-Received: from localhost ([::1]:42959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abuWl-0006e1-1t for ged-emacs-devel@m.gmane.org; Fri, 04 Mar 2016 13:32:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abuWi-0006dr-FQ for emacs-devel@gnu.org; Fri, 04 Mar 2016 13:32:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abuWe-0008Cw-Cy for emacs-devel@gnu.org; Fri, 04 Mar 2016 13:32:36 -0500 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:36914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abuWe-0008Cr-5b for emacs-devel@gnu.org; Fri, 04 Mar 2016 13:32:32 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 689E39D2003; Fri, 4 Mar 2016 19:32:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CzQguukzrWg3; Fri, 4 Mar 2016 19:32:24 +0100 (CET) Original-Received: from localhost (unknown [109.232.24.28]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 1ABD59D2002; Fri, 4 Mar 2016 19:32:24 +0100 (CET) User-agent: mu4e 0.9.13; emacs 25.1.50.6 In-reply-to: <878u1y89my.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200918 Archived-At: On 2016-03-04, at 17:56, Vitalie Spinu wrote: >>> On Fri, Mar 04 2016 15:16, Marcin Borkowski wrote: > >> On 2016-03-04, at 14:36, Vitalie Spinu 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