]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/nadvice.el (advice--member-p): Return the advice if found.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 6 May 2013 15:27:11 +0000 (11:27 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 6 May 2013 15:27:11 +0000 (11:27 -0400)
(advice--add-function): Refresh the advice if already present.

Fixes: debbugs:14317
lisp/ChangeLog
lisp/emacs-lisp/nadvice.el

index 5abb4954a97740e1ea61707999399b8d374d56ae..dd7b8456368c589172bb44362179c6c46ac0a944 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/nadvice.el (advice--member-p): Return the advice if found.
+       (advice--add-function): Refresh the advice if already present
+       (bug#14317).
+
 2013-05-06  Ivan Andrus  <darthandrus@gmail.com>
 
        * find-file.el (cc-other-file-alist): Add ".m" for ObjC.  (Bug#14339)
index 12166553a143cce1022c5814faaf480a18901cc3..c08d671e7eb939c40ac4fb66adf7ea0faa4e4a6b 100644 (file)
@@ -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))))