summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/nadvice.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-05-06 11:27:11 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-05-06 11:27:11 -0400
commitc67c08396aa234f7d651f80cc531cd8ee57c6701 (patch)
tree8d24067d7f47a93fd0177063a377104d06beb4ec /lisp/emacs-lisp/nadvice.el
parent7a6018ad21c87ae7adda785b115851d662d5c2e9 (diff)
downloademacs-c67c08396aa234f7d651f80cc531cd8ee57c6701.tar.gz
* lisp/emacs-lisp/nadvice.el (advice--member-p): Return the advice if found.
(advice--add-function): Refresh the advice if already present. Fixes: debbugs:14317
Diffstat (limited to 'lisp/emacs-lisp/nadvice.el')
-rw-r--r--lisp/emacs-lisp/nadvice.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 12166553a14..c08d671e7eb 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -167,7 +167,7 @@ WHERE is a symbol to select an entry in `advice--where-alist'."
(if (or (equal function (advice--car definition))
(when name
(equal name (cdr (assq 'name (advice--props definition))))))
- (setq found t)
+ (setq found definition)
(setq definition (advice--cdr definition))))
found))
@@ -260,8 +260,12 @@ is also interactive. There are 3 cases:
;;;###autoload
(defun advice--add-function (where ref function props)
- (unless (advice--member-p function (cdr (assq 'name props))
- (gv-deref ref))
+ (let ((a (advice--member-p function (cdr (assq 'name props))
+ (gv-deref ref))))
+ (when a
+ ;; The advice is already present. Remove the old one, first.
+ (setf (gv-deref ref)
+ (advice--remove-function (gv-deref ref) (advice--car a))))
(setf (gv-deref ref)
(advice--make where function (gv-deref ref) props))))