diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-04-15 11:06:51 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-04-15 11:06:51 -0400 |
commit | dabefae5beace8691ea548949c32686872ef9989 (patch) | |
tree | 05513802b2ee052d3be89aadd2ec55f0a012294e /lisp/emacs-lisp | |
parent | 85c9ab6469de468202fee8d17b63258b00bc76d3 (diff) | |
download | emacs-dabefae5beace8691ea548949c32686872ef9989.tar.gz emacs-dabefae5beace8691ea548949c32686872ef9989.tar.bz2 emacs-dabefae5beace8691ea548949c32686872ef9989.zip |
* lisp/emacs-lisp/nadvice.el: Properly test names when adding advice.
(advice--member-p): New arg `name'.
(advice--add-function, advice-member-p): Use it.
Fixes: debbugs:14202
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/nadvice.el | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 0632c7d2fc0..db8a0753466 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -158,11 +158,12 @@ WHERE is a symbol to select an entry in `advice--where-alist'." (advice--make-1 (nth 1 desc) (nth 2 desc) function main props))) -(defun advice--member-p (function definition) +(defun advice--member-p (function name definition) (let ((found nil)) (while (and (not found) (advice--p definition)) (if (or (equal function (advice--car definition)) - (equal function (cdr (assq 'name (advice--props definition))))) + (when name + (equal name (cdr (assq 'name (advice--props definition)))))) (setq found t) (setq definition (advice--cdr definition)))) found)) @@ -255,7 +256,8 @@ is also interactive. There are 3 cases: ;;;###autoload (defun advice--add-function (where ref function props) - (unless (advice--member-p function (gv-deref ref)) + (unless (advice--member-p function (cdr (assq 'name props)) + (gv-deref ref)) (setf (gv-deref ref) (advice--make where function (gv-deref ref) props)))) @@ -396,7 +398,7 @@ of the piece of advice." "Return non-nil if ADVICE has been added to FUNCTION-NAME. Instead of ADVICE being the actual function, it can also be the `name' of the piece of advice." - (advice--member-p advice + (advice--member-p advice advice (or (get function-name 'advice--pending) (advice--strip-macro (if (fboundp function-name) |