aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-01-08 10:24:56 -0500
committerStefan Monnier2013-01-08 10:24:56 -0500
commita731fc1bb01f3c0c8eb2ca24a1c5cd7cd7373059 (patch)
treeb7720ad698b8a7fd074d33f9bcbf41d696a81734
parent2a22c83bb05ecd98cee091fdf59d2f687f83f5dc (diff)
downloademacs-a731fc1bb01f3c0c8eb2ca24a1c5cd7cd7373059.tar.gz
emacs-a731fc1bb01f3c0c8eb2ca24a1c5cd7cd7373059.zip
* lisp/emacs-lisp/nadvice.el (advice--tweak): New function.
(advice--remove-function, advice--subst-main): Use it. * lisp/emacs-lisp/advice.el: Update commentary.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/emacs-lisp/advice.el8
-rw-r--r--lisp/emacs-lisp/nadvice.el39
3 files changed, 33 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7e0f4214a7e..3c1a51855ab 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,14 @@
12013-01-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/nadvice.el (advice--tweak): New function.
4 (advice--remove-function, advice--subst-main): Use it.
5
6 * emacs-lisp/advice.el: Update commentary.
7
12013-01-08 Michael Albinus <michael.albinus@gmx.de> 82013-01-08 Michael Albinus <michael.albinus@gmx.de>
2 9
3 * net/tramp-adb.el (tramp-adb-file-name-handler-alist): Remove 10 * net/tramp-adb.el (tramp-adb-file-name-handler-alist):
4 spurious entry. 11 Remove spurious entry.
5 12
62013-01-08 Glenn Morris <rgm@gnu.org> 132013-01-08 Glenn Morris <rgm@gnu.org>
7 14
@@ -26,8 +33,8 @@
26 33
272013-01-07 Bastien Guerry <bzg@gnu.org> 342013-01-07 Bastien Guerry <bzg@gnu.org>
28 35
29 * menu-bar.el (menu-bar-search-documentation-menu): Use 36 * menu-bar.el (menu-bar-search-documentation-menu):
30 `apropos-user-option' and fix the help message. 37 Use `apropos-user-option' and fix the help message.
31 38
322013-01-07 Bastien Guerry <bzg@gnu.org> 392013-01-07 Bastien Guerry <bzg@gnu.org>
33 40
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index d9d8e4f3b02..07340f06a13 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -589,13 +589,11 @@
589;; Advice implements forward advice mainly via the following: 1) Separation 589;; Advice implements forward advice mainly via the following: 1) Separation
590;; of advice definition and activation that makes it possible to accumulate 590;; of advice definition and activation that makes it possible to accumulate
591;; advice information without having the original function already defined, 591;; advice information without having the original function already defined,
592;; 2) special versions of the built-in functions `fset/defalias' which check 592;; 2) Use of the `defalias-fset-function' symbol property which lets
593;; for advice information whenever they define a function. If advice 593;; us advise the function when it gets defined.
594;; information was found then the advice will immediately get activated when
595;; the function gets defined.
596 594
597;; Automatic advice activation means, that whenever a function gets defined 595;; Automatic advice activation means, that whenever a function gets defined
598;; with either `defun', `defmacro', `fset' or by loading a byte-compiled 596;; with either `defun', `defmacro', `defalias' or by loading a byte-compiled
599;; file, and the function has some advice-info stored with it then that 597;; file, and the function has some advice-info stored with it then that
600;; advice will get activated right away. 598;; advice will get activated right away.
601 599
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index b4d6fac92a2..1715763d482 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -167,20 +167,26 @@ WHERE is a symbol to select an entry in `advice--where-alist'."
167 (setq definition (advice--cdr definition)))) 167 (setq definition (advice--cdr definition))))
168 found)) 168 found))
169 169
170;;;###autoload 170(defun advice--tweak (flist tweaker)
171(defun advice--remove-function (flist function)
172 (if (not (advice--p flist)) 171 (if (not (advice--p flist))
173 flist 172 (funcall tweaker nil flist nil)
174 (let ((first (advice--car flist)) 173 (let ((first (advice--car flist))
174 (rest (advice--cdr flist))
175 (props (advice--props flist))) 175 (props (advice--props flist)))
176 (if (or (equal function first) 176 (or (funcall tweaker first rest props)
177 (equal function (cdr (assq 'name props)))) 177 (let ((nrest (advice--tweak rest tweaker)))
178 (advice--cdr flist) 178 (if (eq rest nrest) flist
179 (let* ((rest (advice--cdr flist)) 179 (advice--make-1 (aref flist 1) (aref flist 3)
180 (nrest (advice--remove-function rest function))) 180 first nrest props)))))))
181 (if (eq rest nrest) flist 181
182 (advice--make-1 (aref flist 1) (aref flist 3) 182;;;###autoload
183 first nrest props))))))) 183(defun advice--remove-function (flist function)
184 (advice--tweak flist
185 (lambda (first rest props)
186 (if (or (not first)
187 (equal function first)
188 (equal function (cdr (assq 'name props))))
189 rest))))
184 190
185(defvar advice--buffer-local-function-sample nil) 191(defvar advice--buffer-local-function-sample nil)
186 192
@@ -269,15 +275,8 @@ of the piece of advice."
269;;;; Specific application of add-function to `symbol-function' for advice. 275;;;; Specific application of add-function to `symbol-function' for advice.
270 276
271(defun advice--subst-main (old new) 277(defun advice--subst-main (old new)
272 (if (not (advice--p old)) 278 (advice--tweak old
273 new 279 (lambda (first _rest _props) (if (not first) new))))
274 (let* ((first (advice--car old))
275 (rest (advice--cdr old))
276 (props (advice--props old))
277 (nrest (advice--subst-main rest new)))
278 (if (equal rest nrest) old
279 (advice--make-1 (aref old 1) (aref old 3)
280 first nrest props)))))
281 280
282(defun advice--normalize (symbol def) 281(defun advice--normalize (symbol def)
283 (cond 282 (cond