aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2013-01-15 01:05:22 -0500
committerStefan Monnier2013-01-15 01:05:22 -0500
commitcb9c0a53bc4a6d67f10d4674472b2884a71852c8 (patch)
treebf43c694ff8de8bc246c19bdc929a336e3dd969b /lisp
parentef8214345ba7b46de9837fbe9461e19f18e6d660 (diff)
downloademacs-cb9c0a53bc4a6d67f10d4674472b2884a71852c8.tar.gz
emacs-cb9c0a53bc4a6d67f10d4674472b2884a71852c8.zip
* lisp/emacs-lisp/advice.el (ad-preactivate-advice): Adjust the cleanup to
the use of nadvice.el. * lisp/emacs-lisp/nadvice.el (advice--tweak): Make it possible for `tweak' to return an explicit nil. (advice--remove-function): Change accordingly. * test/automated/advice-tests.el: Split up. Add advice-test-preactivate.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/advice.el13
-rw-r--r--lisp/emacs-lisp/nadvice.el11
3 files changed, 18 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 56770098b43..f324ebbad51 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12013-01-15 Stefan Monnier <monnier@iro.umontreal.ca> 12013-01-15 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/nadvice.el (advice--tweak): Make it possible for `tweak'
4 to return an explicit nil.
5 (advice--remove-function): Change accordingly.
6
7 * emacs-lisp/advice.el (ad-preactivate-advice): Adjust the cleanup to
8 the use of nadvice.el.
9
3 * progmodes/which-func.el (which-function): Silence imenu errors 10 * progmodes/which-func.el (which-function): Silence imenu errors
4 (bug#13433). 11 (bug#13433).
5 12
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 07340f06a13..3d03e894534 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -2866,10 +2866,8 @@ advised definition from scratch."
2866 2866
2867(defun ad-preactivate-advice (function advice class position) 2867(defun ad-preactivate-advice (function advice class position)
2868 "Preactivate FUNCTION and returns the constructed cache." 2868 "Preactivate FUNCTION and returns the constructed cache."
2869 (let* ((function-defined-p (fboundp function)) 2869 (let* ((advicefunname (ad-get-advice-info-field function 'advicefunname))
2870 (old-definition 2870 (old-advice (symbol-function advicefunname))
2871 (if function-defined-p
2872 (symbol-function function)))
2873 (old-advice-info (ad-copy-advice-info function)) 2871 (old-advice-info (ad-copy-advice-info function))
2874 (ad-advised-functions ad-advised-functions)) 2872 (ad-advised-functions ad-advised-functions))
2875 (unwind-protect 2873 (unwind-protect
@@ -2883,10 +2881,9 @@ advised definition from scratch."
2883 (list (ad-get-cache-definition function) 2881 (list (ad-get-cache-definition function)
2884 (ad-get-cache-id function)))) 2882 (ad-get-cache-id function))))
2885 (ad-set-advice-info function old-advice-info) 2883 (ad-set-advice-info function old-advice-info)
2886 ;; Don't `fset' function to nil if it was previously unbound: 2884 (advice-remove function advicefunname)
2887 (if function-defined-p 2885 (fset advicefunname old-advice)
2888 (fset function old-definition) 2886 (if old-advice (advice-add function :around advicefunname)))))
2889 (fmakunbound function)))))
2890 2887
2891 2888
2892;; @@ Activation and definition handling: 2889;; @@ Activation and definition handling:
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 1715763d482..b0711fed26c 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -173,20 +173,21 @@ WHERE is a symbol to select an entry in `advice--where-alist'."
173 (let ((first (advice--car flist)) 173 (let ((first (advice--car flist))
174 (rest (advice--cdr flist)) 174 (rest (advice--cdr flist))
175 (props (advice--props flist))) 175 (props (advice--props flist)))
176 (or (funcall tweaker first rest props) 176 (let ((val (funcall tweaker first rest props)))
177 (if val (car val)
177 (let ((nrest (advice--tweak rest tweaker))) 178 (let ((nrest (advice--tweak rest tweaker)))
178 (if (eq rest nrest) flist 179 (if (eq rest nrest) flist
179 (advice--make-1 (aref flist 1) (aref flist 3) 180 (advice--make-1 (aref flist 1) (aref flist 3)
180 first nrest props))))))) 181 first nrest props))))))))
181 182
182;;;###autoload 183;;;###autoload
183(defun advice--remove-function (flist function) 184(defun advice--remove-function (flist function)
184 (advice--tweak flist 185 (advice--tweak flist
185 (lambda (first rest props) 186 (lambda (first rest props)
186 (if (or (not first) 187 (cond ((not first) rest)
187 (equal function first) 188 ((or (equal function first)
188 (equal function (cdr (assq 'name props)))) 189 (equal function (cdr (assq 'name props))))
189 rest)))) 190 (list rest))))))
190 191
191(defvar advice--buffer-local-function-sample nil) 192(defvar advice--buffer-local-function-sample nil)
192 193