diff options
| author | Stefan Monnier | 2013-04-15 11:06:51 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-04-15 11:06:51 -0400 |
| commit | dabefae5beace8691ea548949c32686872ef9989 (patch) | |
| tree | 05513802b2ee052d3be89aadd2ec55f0a012294e | |
| parent | 85c9ab6469de468202fee8d17b63258b00bc76d3 (diff) | |
| download | emacs-dabefae5beace8691ea548949c32686872ef9989.tar.gz emacs-dabefae5beace8691ea548949c32686872ef9989.zip | |
* lisp/emacs-lisp/nadvice.el: Properly test names when adding advice.
(advice--member-p): New arg `name'.
(advice--add-function, advice-member-p): Use it.
Fixes: debbugs:14202
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/nadvice.el | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d367ddb36f8..2966af7e0bc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-04-15 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/nadvice.el: Properly test names when adding advice. | ||
| 4 | (advice--member-p): New arg `name'. | ||
| 5 | (advice--add-function, advice-member-p): Use it (bug#14202). | ||
| 6 | |||
| 1 | 2013-04-15 Filipp Gunbin <fgunbin@fastmail.fm> | 7 | 2013-04-15 Filipp Gunbin <fgunbin@fastmail.fm> |
| 2 | 8 | ||
| 3 | Reformulate java imenu-generic-expression. | 9 | Reformulate java imenu-generic-expression. |
| @@ -7,7 +13,7 @@ | |||
| 7 | (cc-imenu-java-type-spec-regexp, cc-imenu-java-comment-regexp) | 13 | (cc-imenu-java-type-spec-regexp, cc-imenu-java-comment-regexp) |
| 8 | (cc-imenu-java-method-arg-regexp): New defconsts. | 14 | (cc-imenu-java-method-arg-regexp): New defconsts. |
| 9 | (cc-imenu-java-build-type-args-regex): New defun. | 15 | (cc-imenu-java-build-type-args-regex): New defun. |
| 10 | (cc-imenu-java-generic-expression): Fixed, to remove "ambiguous" | 16 | (cc-imenu-java-generic-expression): Fix, to remove "ambiguous" |
| 11 | handling of spaces in the regexp. | 17 | handling of spaces in the regexp. |
| 12 | 18 | ||
| 13 | 2013-03-15 Agustín Martín Domingo <agustin.martin@hispalinux.es> | 19 | 2013-03-15 Agustín Martín Domingo <agustin.martin@hispalinux.es> |
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 0632c7d2fc0..db8a0753466 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el | |||
| @@ -158,11 +158,12 @@ WHERE is a symbol to select an entry in `advice--where-alist'." | |||
| 158 | (advice--make-1 (nth 1 desc) (nth 2 desc) | 158 | (advice--make-1 (nth 1 desc) (nth 2 desc) |
| 159 | function main props))) | 159 | function main props))) |
| 160 | 160 | ||
| 161 | (defun advice--member-p (function definition) | 161 | (defun advice--member-p (function name definition) |
| 162 | (let ((found nil)) | 162 | (let ((found nil)) |
| 163 | (while (and (not found) (advice--p definition)) | 163 | (while (and (not found) (advice--p definition)) |
| 164 | (if (or (equal function (advice--car definition)) | 164 | (if (or (equal function (advice--car definition)) |
| 165 | (equal function (cdr (assq 'name (advice--props definition))))) | 165 | (when name |
| 166 | (equal name (cdr (assq 'name (advice--props definition)))))) | ||
| 166 | (setq found t) | 167 | (setq found t) |
| 167 | (setq definition (advice--cdr definition)))) | 168 | (setq definition (advice--cdr definition)))) |
| 168 | found)) | 169 | found)) |
| @@ -255,7 +256,8 @@ is also interactive. There are 3 cases: | |||
| 255 | 256 | ||
| 256 | ;;;###autoload | 257 | ;;;###autoload |
| 257 | (defun advice--add-function (where ref function props) | 258 | (defun advice--add-function (where ref function props) |
| 258 | (unless (advice--member-p function (gv-deref ref)) | 259 | (unless (advice--member-p function (cdr (assq 'name props)) |
| 260 | (gv-deref ref)) | ||
| 259 | (setf (gv-deref ref) | 261 | (setf (gv-deref ref) |
| 260 | (advice--make where function (gv-deref ref) props)))) | 262 | (advice--make where function (gv-deref ref) props)))) |
| 261 | 263 | ||
| @@ -396,7 +398,7 @@ of the piece of advice." | |||
| 396 | "Return non-nil if ADVICE has been added to FUNCTION-NAME. | 398 | "Return non-nil if ADVICE has been added to FUNCTION-NAME. |
| 397 | Instead of ADVICE being the actual function, it can also be the `name' | 399 | Instead of ADVICE being the actual function, it can also be the `name' |
| 398 | of the piece of advice." | 400 | of the piece of advice." |
| 399 | (advice--member-p advice | 401 | (advice--member-p advice advice |
| 400 | (or (get function-name 'advice--pending) | 402 | (or (get function-name 'advice--pending) |
| 401 | (advice--strip-macro | 403 | (advice--strip-macro |
| 402 | (if (fboundp function-name) | 404 | (if (fboundp function-name) |