[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

17.3 Around-Advice

Around-advice lets you “wrap” a Lisp expression “around” the original function definition. You specify where the original function definition should go by means of the special symbol ad-do-it. Where this symbol occurs inside the around-advice body, it is replaced with a progn containing the forms of the surrounded code. Here is an example:

 
(defadvice foo (around foo-around)
  "Ignore case in `foo'."
  (let ((case-fold-search t))
    ad-do-it))

Its effect is to make sure that case is ignored in searches when the original definition of foo is run.

Variable: ad-do-it

This is not really a variable, rather a place-holder that looks like a variable. You use it in around-advice to specify the place to run the function's original definition and other “earlier” around-advice.

If the around-advice does not use ad-do-it, then it does not run the original function definition. This provides a way to override the original definition completely. (It also overrides lower-positioned pieces of around-advice).

If the around-advice uses ad-do-it more than once, the original definition is run at each place. In this way, around-advice can execute the original definition (and lower-positioned pieces of around-advice) several times. Another way to do that is by using ad-do-it inside of a loop.


Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.