diff options
| author | Stefan Monnier | 2012-11-13 09:12:46 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2012-11-13 09:12:46 -0500 |
| commit | 3c442f8b25bf6acc52c45a1f9966b8529ea936d2 (patch) | |
| tree | d6372faa4eef5ed4919e94592240b06634e0a4c8 /test | |
| parent | c708524567662c8911c5ab2695acc7bda0383705 (diff) | |
| download | emacs-3c442f8b25bf6acc52c45a1f9966b8529ea936d2.tar.gz emacs-3c442f8b25bf6acc52c45a1f9966b8529ea936d2.zip | |
* 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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/advice-tests.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index 9f9719fdcfc..8f9bf54114c 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el | |||
| @@ -57,6 +57,29 @@ | |||
| 57 | (defmacro sm-test3 (x) `(call-test3 ,x)) | 57 | (defmacro sm-test3 (x) `(call-test3 ,x)) |
| 58 | (macroexpand '(sm-test3 56)) (toto (call-test3 56))) | 58 | (macroexpand '(sm-test3 56)) (toto (call-test3 56))) |
| 59 | 59 | ||
| 60 | ((defadvice sm-test4 (around wrap-with-toto activate) | ||
| 61 | ad-do-it (setq ad-return-value `(toto ,ad-return-value))) | ||
| 62 | (defmacro sm-test4 (x) `(call-test4 ,x)) | ||
| 63 | (macroexpand '(sm-test4 56)) (toto (call-test4 56))) | ||
| 64 | ((defmacro sm-test4 (x) `(call-testq ,x)) | ||
| 65 | (macroexpand '(sm-test4 56)) (toto (call-testq 56))) | ||
| 66 | |||
| 67 | ;; Combining old style and new style advices. | ||
| 68 | ((defun sm-test5 (x) (+ x 4)) | ||
| 69 | (sm-test5 6) 10) | ||
| 70 | ((advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5))) | ||
| 71 | (sm-test5 6) 50) | ||
| 72 | ((defadvice sm-test5 (around test activate) | ||
| 73 | ad-do-it (setq ad-return-value (+ ad-return-value 0.1))) | ||
| 74 | (sm-test5 5) 45.1) | ||
| 75 | ((ad-deactivate 'sm-test5) | ||
| 76 | (sm-test5 6) 50) | ||
| 77 | ((ad-activate 'sm-test5) | ||
| 78 | (sm-test5 6) 50.1) | ||
| 79 | ((defun sm-test5 (x) (+ x 14)) | ||
| 80 | (sm-test5 6) 100.1) | ||
| 81 | ((advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5))) | ||
| 82 | (sm-test5 6) 20.1) | ||
| 60 | )) | 83 | )) |
| 61 | 84 | ||
| 62 | (ert-deftest advice-tests () | 85 | (ert-deftest advice-tests () |