From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nic Ferrier Newsgroups: gmane.emacs.devel Subject: Re: define-advice, advise, defnadvice, advice-advise you name it Date: Sun, 16 Nov 2014 22:20:29 +0000 Message-ID: <87fvdilrde.fsf@ferrier.me.uk> References: <87sihisveo.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416176463 19438 80.91.229.3 (16 Nov 2014 22:21:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Nov 2014 22:21:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Liu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 16 23:20:56 2014 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 1Xq8Bk-00062i-5Z for ged-emacs-devel@m.gmane.org; Sun, 16 Nov 2014 23:20:56 +0100 Original-Received: from localhost ([::1]:45235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xq8Bj-0002fj-Mq for ged-emacs-devel@m.gmane.org; Sun, 16 Nov 2014 17:20:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xq8BZ-0002fa-Jz for emacs-devel@gnu.org; Sun, 16 Nov 2014 17:20:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xq8BN-0005oQ-QG for emacs-devel@gnu.org; Sun, 16 Nov 2014 17:20:45 -0500 Original-Received: from static.17.66.46.78.clients.your-server.de ([78.46.66.17]:58557 helo=po1.ferrier.me.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xq8BN-0005o5-JL for emacs-devel@gnu.org; Sun, 16 Nov 2014 17:20:33 -0500 Original-Received: from nicferrier-dell-xps (140.35.155.90.in-addr.arpa [90.155.35.140]) by po1.ferrier.me.uk (Postfix) with ESMTPA id 74734AC00AA; Sun, 16 Nov 2014 23:39:12 +0100 (CET) Original-Received: from nicferrier-XPS13-9333 (localhost [127.0.0.1]) by nicferrier-dell-xps (Postfix) with ESMTPS id 6ADE66BA00; Sun, 16 Nov 2014 22:20:29 +0000 (GMT) In-Reply-To: <87sihisveo.fsf@gmail.com> (Leo Liu's message of "Mon, 17 Nov 2014 05:11:27 +0800") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.46.66.17 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:177364 Archived-At: Leo Liu writes: > (defmacro define-advice (symbol args &rest body) > "Define an advice and add it to function named SYMBOL. > See `advice-add' and `add-function' for explanation on the > arguments. Note if NAME is nil the advice is anonymous; > otherwise it is named `SYMBOL@NAME'. > > \(fn SYMBOL (WHERE LAMBDA-LIST &optional NAME DEPTH) &rest BODY)" > (declare (indent 2) (doc-string 3) (debug (sexp sexp body))) > (or (listp args) (signal 'wrong-type-argument (list 'listp args))) > (or (<= 2 (length args) 4) > (signal 'wrong-number-of-arguments (list 2 4 (length args)))) > (let* ((where (nth 0 args)) > (lambda-list (nth 1 args)) > (name (nth 2 args)) > (depth (nth 3 args)) > (props (and depth `((depth . ,depth)))) > (advice (cond ((null name) `(lambda ,lambda-list ,@body)) > ((or (stringp name) (symbolp name)) > (intern (format "%s@%s" symbol name))) > (t (error "Unrecognized name spec `%S'" name))))) > `(prog1 ,@(and (symbolp advice) `((defun ,advice ,lambda-list ,@body))) > (advice-add ',symbol ,where #',advice ,@(and props `(',props)))))) > > > So does anyone have something that sounds advicey and macroish? push-advice? Nic