emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: define-advice, advise, defnadvice, advice-advise you name it


From: Nic Ferrier
Subject: Re: define-advice, advise, defnadvice, advice-advise you name it
Date: Sun, 16 Nov 2014 22:20:29 +0000

Leo Liu <address@hidden> 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 address@hidden'.
>    
>    \(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 "address@hidden" 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 via email to

[Prev in Thread] Current Thread [Next in Thread]