diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-08-04 16:18:11 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-08-04 16:18:11 -0400 |
commit | 671d5c16547d16bef2efa056705bd35b5feacc29 (patch) | |
tree | 4bc2c3774ce9914f21508d0e2a83e25504dbc1db /lisp/emacs-lisp/nadvice.el | |
parent | e443729d658ee2b9e0f55bbbb90241819bf516a6 (diff) | |
download | emacs-671d5c16547d16bef2efa056705bd35b5feacc29.tar.gz |
* lisp/subr.el (macrop): New function.
(text-clone--maintaining): New var.
(text-clone--maintain): Rename from text-clone-maintain. Use it
instead of inhibit-modification-hooks.
* lisp/emacs-lisp/nadvice.el (advice--normalize): For aliases to macros, use
a proxy, so as handle autoloads and redefinitions of the target.
(advice--defalias-fset, advice-remove): Use advice--symbol-function.
* lisp/emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates):
Remove bogus (arrayp . stringp) pair. Add entries for `vectorp'.
(pcase--mutually-exclusive-p): New function.
(pcase--split-consp): Use it.
(pcase--split-pred): Use it. Optimize the case where `pat' is a qpat
mutually exclusive with the current predicate.
* test/automated/advice-tests.el (advice-tests-nadvice): Test removal
before definition.
(advice-tests-macroaliases): New test.
* lisp/emacs-lisp/edebug.el (edebug-lookup-function): Remove function.
(edebug-macrop): Remove. Use `macrop' instead.
* lisp/emacs-lisp/advice.el (ad-subr-p): Remove. Use `subrp' instead.
(ad-macro-p):
* lisp/eshell/esh-cmd.el (eshell-macrop):
* lisp/apropos.el (apropos-macrop): Remove. Use `macrop' instead.
Diffstat (limited to 'lisp/emacs-lisp/nadvice.el')
-rw-r--r-- | lisp/emacs-lisp/nadvice.el | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 660eb0365ae..576e72088e9 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -314,9 +314,8 @@ of the piece of advice." ((special-form-p def) ;; Not worth the trouble trying to handle this, I think. (error "Advice impossible: %S is a special form" symbol)) - ((and (symbolp def) - (eq 'macro (car-safe (ignore-errors (indirect-function def))))) - (let ((newval (cons 'macro (cdr (indirect-function def))))) + ((and (symbolp def) (macrop def)) + (let ((newval `(macro . ,(lambda (&rest r) (macroexpand `(,def . ,r)))))) (put symbol 'advice--saved-rewrite (cons def (cdr newval))) newval)) ;; `f' might be a pure (hence read-only) cons! @@ -351,19 +350,7 @@ of the piece of advice." (when (get symbol 'advice--saved-rewrite) (put symbol 'advice--saved-rewrite nil)) (setq newdef (advice--normalize symbol newdef)) - (let* ((olddef (advice--strip-macro (symbol-function symbol))) - (oldadv - (cond - ((null (get symbol 'advice--pending)) - (or olddef - (progn - (message "Delayed advice activation failed for %s: no data" - symbol) - nil))) - ((or (not olddef) (autoloadp olddef)) - (get symbol 'advice--pending)) - (t (message "Dropping left-over advice--pending for %s" symbol) - olddef)))) + (let ((oldadv (advice--symbol-function symbol))) (if (and newdef (not (autoloadp newdef))) (let* ((snewdef (advice--strip-macro newdef)) (snewadv (advice--subst-main oldadv snewdef))) @@ -383,7 +370,6 @@ is defined as a macro, alias, command, ..." ;; TODO: ;; - record the advice location, to display in describe-function. ;; - change all defadvice in lisp/**/*.el. - ;; - rewrite advice.el on top of this. ;; - obsolete advice.el. (let* ((f (symbol-function symbol)) (nf (advice--normalize symbol f))) @@ -420,8 +406,7 @@ of the piece of advice." ((eq (car-safe f) 'macro) (cdr f)) (t (symbol-function symbol))) function) - (unless (advice--p - (if (eq (car-safe f) 'macro) (cdr f) (symbol-function symbol))) + (unless (advice--p (advice--symbol-function symbol)) ;; Not advised any more. (remove-function (get symbol 'defalias-fset-function) #'advice--defalias-fset) |