emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112478: * lisp/emacs-lisp/nadvice.el


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112478: * lisp/emacs-lisp/nadvice.el (advice--member-p): Return the advice if found.
Date: Mon, 06 May 2013 11:27:11 -0400
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112478
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14317
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2013-05-06 11:27:11 -0400
message:
  * lisp/emacs-lisp/nadvice.el (advice--member-p): Return the advice if found.
  (advice--add-function): Refresh the advice if already present.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/nadvice.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-06 07:40:58 +0000
+++ b/lisp/ChangeLog    2013-05-06 15:27:11 +0000
@@ -1,3 +1,9 @@
+2013-05-06  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * find-file.el (cc-other-file-alist): Add ".m" for ObjC.  (Bug#14339)

=== modified file 'lisp/emacs-lisp/nadvice.el'
--- a/lisp/emacs-lisp/nadvice.el        2013-04-20 16:24:04 +0000
+++ b/lisp/emacs-lisp/nadvice.el        2013-05-06 15:27:11 +0000
@@ -167,7 +167,7 @@
       (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 @@
 
 ;;;###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))))
 


reply via email to

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