Commit 3c442f8b authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp/emacs-lisp/advice.el: Layer on top of nadvice.el.

Remove out of date self-require hack.
(ad-do-advised-functions): Use simple `dolist'.
(ad-advice-name, ad-advice-protected, ad-advice-enabled)
(ad-advice-definition): Redefine as functions.
(ad-advice-classes): Move before first use.
(ad-make-origname, ad-set-orig-definition, ad-clear-orig-definition)
(ad-make-mapped-call, ad-make-advised-docstring, ad-make-plain-docstring)
(ad--defalias-fset): Remove functions.
(ad-make-advicefunname, ad-clear-advicefunname-definition): New functions.
(ad-get-orig-definition): Rewrite.
(ad-make-advised-definition-docstring): Change base docstring.
(ad-real-orig-definition): Rewrite.
(ad-map-arglists): Change name of called function.
(ad--make-advised-docstring): Redirect `function' from ad-Advice-...
(ad-make-advised-definition): Simplify.
(ad-assemble-advised-definition): Tweak for new calling context.
(ad-activate-advised-definition): Setup ad-Advice-* instead of ad-Orig-*.
(ad--defalias-fset): Rename from ad-handle-definition.  Make it set the
function and call ad-activate if needed.
(ad-activate, ad-deactivate): Don't call ad-handle-definition any more.
(ad-recover): Clear ad-Advice-* instead of ad-Orig-*.
(ad-compile-function): Compile ad-Advice-*.
(ad-activate-on-top-level, ad-with-auto-activation-disabled): Remove.
(ad-start-advice, ad-stop-advice): Remove.
parent c7085245
......@@ -43,7 +43,8 @@ It is layered as:
* Incompatible Lisp Changes in Emacs 24.4
** `defadvice' does not honor the `freeze' flag any more.
** `defadvice' does not honor the `freeze' flag and cannot advise
special-forms any more.
** `dolist' in lexical-binding mode does not bind VAR in RESULT any more.
VAR was bound to nil which was not tremendously useful and just lead to
......
2012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/advice.el: Layer on top of nadvice.el.
Remove out of date self-require hack.
(ad-do-advised-functions): Use simple `dolist'.
(ad-advice-name, ad-advice-protected, ad-advice-enabled)
(ad-advice-definition): Redefine as functions.
(ad-advice-classes): Move before first use.
(ad-make-origname, ad-set-orig-definition, ad-clear-orig-definition)
(ad-make-mapped-call, ad-make-advised-docstring, ad-make-plain-docstring)
(ad--defalias-fset): Remove functions.
(ad-make-advicefunname, ad-clear-advicefunname-definition): New functions.
(ad-get-orig-definition): Rewrite.
(ad-make-advised-definition-docstring): Change base docstring.
(ad-real-orig-definition): Rewrite.
(ad-map-arglists): Change name of called function.
(ad--make-advised-docstring): Redirect `function' from ad-Advice-...
(ad-make-advised-definition): Simplify.
(ad-assemble-advised-definition): Tweak for new calling context.
(ad-activate-advised-definition): Setup ad-Advice-* instead of ad-Orig-*.
(ad--defalias-fset): Rename from ad-handle-definition. Make it set the
function and call ad-activate if needed.
(ad-activate, ad-deactivate): Don't call ad-handle-definition any more.
(ad-recover): Clear ad-Advice-* instead of ad-Orig-*.
(ad-compile-function): Compile ad-Advice-*.
(ad-activate-on-top-level, ad-with-auto-activation-disabled): Remove.
(ad-start-advice, ad-stop-advice): Remove.
2012-11-13 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-add-log-current-method): Print the
......
This diff is collapsed.
......@@ -57,6 +57,29 @@
(defmacro sm-test3 (x) `(call-test3 ,x))
(macroexpand '(sm-test3 56)) (toto (call-test3 56)))
((defadvice sm-test4 (around wrap-with-toto activate)
ad-do-it (setq ad-return-value `(toto ,ad-return-value)))
(defmacro sm-test4 (x) `(call-test4 ,x))
(macroexpand '(sm-test4 56)) (toto (call-test4 56)))
((defmacro sm-test4 (x) `(call-testq ,x))
(macroexpand '(sm-test4 56)) (toto (call-testq 56)))
;; Combining old style and new style advices.
((defun sm-test5 (x) (+ x 4))
(sm-test5 6) 10)
((advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5)))
(sm-test5 6) 50)
((defadvice sm-test5 (around test activate)
ad-do-it (setq ad-return-value (+ ad-return-value 0.1)))
(sm-test5 5) 45.1)
((ad-deactivate 'sm-test5)
(sm-test5 6) 50)
((ad-activate 'sm-test5)
(sm-test5 6) 50.1)
((defun sm-test5 (x) (+ x 14))
(sm-test5 6) 100.1)
((advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5)))
(sm-test5 6) 20.1)
))
(ert-deftest advice-tests ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment