[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 r117143: * lisp/emacs-lisp/nadvice.el (advice--me
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] emacs-24 r117143: * lisp/emacs-lisp/nadvice.el (advice--member-p): Change second arg. |
Date: |
Fri, 23 May 2014 16:17:20 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117143
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17531
committer: Stefan Monnier <address@hidden>
branch nick: emacs-24
timestamp: Fri 2014-05-23 12:17:14 -0400
message:
* lisp/emacs-lisp/nadvice.el (advice--member-p): Change second arg.
(advice-function-member-p): Tell it to check both names and functions.
(advice--add-function): Adjust call accordingly.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/emacs-lisp/nadvice.el nadvice.el-20121015213644-851fdxs2vximj8nr-1
test/automated/advice-tests.el advice.el-20121111003311-i96f8i1au0zeaju7-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-05-23 12:10:50 +0000
+++ b/lisp/ChangeLog 2014-05-23 16:17:14 +0000
@@ -1,3 +1,10 @@
+2014-05-23 Stefan Monnier <address@hidden>
+
+ * emacs-lisp/nadvice.el (advice--member-p): Change second arg.
+ (advice-function-member-p): Tell it to check both names and functions
+ (bug#17531).
+ (advice--add-function): Adjust call accordingly.
+
2014-05-23 Stephen Berman <address@hidden>
* calendar/todo-mode.el: Miscellaneous bug fixes.
=== modified file 'lisp/emacs-lisp/nadvice.el'
--- a/lisp/emacs-lisp/nadvice.el 2014-05-12 05:25:34 +0000
+++ b/lisp/emacs-lisp/nadvice.el 2014-05-23 16:17:14 +0000
@@ -180,12 +180,16 @@
(advice--make-1 (nth 1 desc) (nth 2 desc)
function main props)))))
-(defun advice--member-p (function name definition)
+(defun advice--member-p (function use-name definition)
(let ((found nil))
(while (and (not found) (advice--p definition))
- (if (if name
- (equal name (cdr (assq 'name (advice--props definition))))
- (equal function (advice--car definition)))
+ (if (if (eq use-name :use-both)
+ (or (equal function
+ (cdr (assq 'name (advice--props definition))))
+ (equal function (advice--car definition)))
+ (equal function (if use-name
+ (cdr (assq 'name (advice--props definition)))
+ (advice--car definition))))
(setq found definition)
(setq definition (advice--cdr definition))))
found))
@@ -291,7 +295,7 @@
;;;###autoload
(defun advice--add-function (where ref function props)
(let* ((name (cdr (assq 'name props)))
- (a (advice--member-p function name (gv-deref ref))))
+ (a (advice--member-p (or name function) (if name t) (gv-deref ref))))
(when a
;; The advice is already present. Remove the old one, first.
(setf (gv-deref ref)
@@ -323,7 +327,7 @@
"Return non-nil if ADVICE is already in FUNCTION-DEF.
Instead of ADVICE being the actual function, it can also be the `name'
of the piece of advice."
- (advice--member-p advice advice function-def))
+ (advice--member-p advice :use-both function-def))
;;;; Specific application of add-function to `symbol-function' for advice.
=== modified file 'test/automated/advice-tests.el'
--- a/test/automated/advice-tests.el 2014-05-10 20:07:01 +0000
+++ b/test/automated/advice-tests.el 2014-05-23 16:17:14 +0000
@@ -184,6 +184,7 @@
(sm-advice (lambda (x) (if (consp x) (list (* 5 (car x))) (* 4 x)))))
(should (equal (funcall sm-test10 5) 15))
(add-function :filter-args (var sm-test10) sm-advice)
+ (should (advice-function-member-p sm-advice sm-test10))
(should (equal (funcall sm-test10 5) 35))
(add-function :filter-return (var sm-test10) sm-advice)
(should (equal (funcall sm-test10 5) 60))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 r117143: * lisp/emacs-lisp/nadvice.el (advice--member-p): Change second arg.,
Stefan Monnier <=