Merge from emacs-24; up to 2012-12-23T02:41:17Z!rgm@gnu.org
[bpt/emacs.git] / lisp / emacs-lisp / nadvice.el
index 1715763..b0711fe 100644 (file)
@@ -173,20 +173,21 @@ WHERE is a symbol to select an entry in `advice--where-alist'."
     (let ((first (advice--car flist))
           (rest (advice--cdr flist))
           (props (advice--props flist)))
-      (or (funcall tweaker first rest props)
+      (let ((val (funcall tweaker first rest props)))
+        (if val (car val)
           (let ((nrest (advice--tweak rest tweaker)))
             (if (eq rest nrest) flist
               (advice--make-1 (aref flist 1) (aref flist 3)
-                              first nrest props)))))))
+                              first nrest props))))))))
 
 ;;;###autoload
 (defun advice--remove-function (flist function)
   (advice--tweak flist
                  (lambda (first rest props)
-                   (if (or (not first)
-                           (equal function first)
+                   (cond ((not first) rest)
+                         ((or (equal function first)
                            (equal function (cdr (assq 'name props))))
-                       rest))))
+                          (list rest))))))
 
 (defvar advice--buffer-local-function-sample nil)