all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nic Ferrier <nferrier@ferrier.me.uk>
To: Leo Liu <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: define-advice, advise, defnadvice, advice-advise you name it
Date: Sun, 16 Nov 2014 22:20:29 +0000	[thread overview]
Message-ID: <87fvdilrde.fsf@ferrier.me.uk> (raw)
In-Reply-To: <87sihisveo.fsf@gmail.com> (Leo Liu's message of "Mon, 17 Nov 2014 05:11:27 +0800")

Leo Liu <sdl.web@gmail.com> 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



  reply	other threads:[~2014-11-16 22:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-16 21:11 define-advice, advise, defnadvice, advice-advise you name it Leo Liu
2014-11-16 22:20 ` Nic Ferrier [this message]
2014-11-17  4:27   ` Stefan Monnier
2014-11-18 12:52     ` Daniel Colascione

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=87fvdilrde.fsf@ferrier.me.uk \
    --to=nferrier@ferrier.me.uk \
    --cc=emacs-devel@gnu.org \
    --cc=sdl.web@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.