2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1998-1999, 2001-2012 Free Software Foundation, Inc.
4 @c See the file elisp.texi for copying conditions.
5 @setfilename ../../info/advising
6 @node Advising Functions, Debugging, Byte Compilation, Top
7 @chapter Advising Emacs Lisp Functions
8 @cindex advising functions
10 The @dfn{advice} feature lets you add to the existing definition of
11 a function, by @dfn{advising the function}. This is a cleaner method
12 for a library to customize functions defined within Emacs---cleaner
13 than redefining the whole function.
15 @cindex piece of advice
16 Each function can have multiple @dfn{pieces of advice}, each of
17 which can be separately defined and then @dfn{enabled} or
18 @dfn{disabled}. All the enabled pieces of advice for any given
19 function actually take effect when you @dfn{activate advice} for that
20 function, or when you define or redefine the function. Note that
21 enabling a piece of advice and activating advice for a function are
24 Advice is useful for altering the behavior of existing calls to an
25 existing function. If you want the new behavior for new function
26 calls or new key bindings, you should define a new function or
27 command, and have it use the existing function as a subroutine.
29 Advising a function can cause confusion in debugging, since people
30 who debug calls to the original function may not notice that it has
31 been modified with advice. Therefore, if you have the possibility to
32 change the code of that function to run a hook, please solve the
33 problem that way. Advice should be reserved for the cases where you
34 cannot get the function changed. In particular, Emacs's own source
35 files should not put advice on functions in Emacs. There are
36 currently a few exceptions to this convention, but we aim to correct
39 Unless you know what you are doing, do @emph{not} advise a primitive
40 (@pxref{What Is a Function}). Some primitives are used by the advice
41 mechanism; advising them could cause an infinite recursion. Also,
42 many primitives are called directly from C code. Calls to the
43 primitive from Lisp code will take note of the advice, but calls from
44 C code will ignore the advice.
47 * Simple Advice:: A simple example to explain the basics of advice.
48 * Defining Advice:: Detailed description of @code{defadvice}.
49 * Around-Advice:: Wrapping advice around a function's definition.
50 * Computed Advice:: ...is to @code{defadvice} as @code{fset} is to @code{defun}.
51 * Activation of Advice:: Advice doesn't do anything until you activate it.
52 * Enabling Advice:: You can enable or disable each piece of advice.
53 * Preactivation:: Preactivation is a way of speeding up the
54 loading of compiled advice.
55 * Argument Access in Advice:: How advice can access the function's arguments.
56 * Combined Definition:: How advice is implemented.
60 @section A Simple Advice Example
62 The command @code{next-line} moves point down vertically one or more
63 lines; it is the standard binding of @kbd{C-n}. When used on the last
64 line of the buffer, this command inserts a newline to create a line to
65 move to if @code{next-line-add-newlines} is non-@code{nil} (its default
68 Suppose you wanted to add a similar feature to @code{previous-line},
69 which would insert a new line at the beginning of the buffer for the
70 command to move to (when @code{next-line-add-newlines} is
71 non-@code{nil}). How could you do this?
73 You could do it by redefining the whole function, but that is not
74 modular. The advice feature provides a cleaner alternative: you can
75 effectively add your code to the existing function definition, without
76 actually changing or even seeing that definition. Here is how to do
80 (defadvice previous-line (before next-line-at-end
81 (&optional arg try-vscroll))
82 "Insert an empty line when moving up from the top line."
83 (if (and next-line-add-newlines (= arg 1)
84 (save-excursion (beginning-of-line) (bobp)))
90 This expression defines a @dfn{piece of advice} for the function
91 @code{previous-line}. This piece of advice is named
92 @code{next-line-at-end}, and the symbol @code{before} says that it is
93 @dfn{before-advice} which should run before the regular definition of
94 @code{previous-line}. @code{(&optional arg try-vscroll)} specifies
95 how the advice code can refer to the function's arguments.
97 When this piece of advice runs, it creates an additional line, in the
98 situation where that is appropriate, but does not move point to that
99 line. This is the correct way to write the advice, because the normal
100 definition will run afterward and will move back to the newly inserted
103 Defining the advice doesn't immediately change the function
104 @code{previous-line}. That happens when you @dfn{activate} the advice,
108 (ad-activate 'previous-line)
112 This is what actually begins to use the advice that has been defined so
113 far for the function @code{previous-line}. Henceforth, whenever that
114 function is run, whether invoked by the user with @kbd{C-p} or
115 @kbd{M-x}, or called from Lisp, it runs the advice first, and its
116 regular definition second.
118 This example illustrates before-advice, which is one @dfn{class} of
119 advice: it runs before the function's base definition. There are two
120 other advice classes: @dfn{after-advice}, which runs after the base
121 definition, and @dfn{around-advice}, which lets you specify an
122 expression to wrap around the invocation of the base definition.
124 @node Defining Advice
125 @section Defining Advice
126 @cindex defining advice
127 @cindex advice, defining
129 To define a piece of advice, use the macro @code{defadvice}. A call
130 to @code{defadvice} has the following syntax, which is based on the
131 syntax of @code{defun} and @code{defmacro}, but adds more:
135 (defadvice @var{function} (@var{class} @var{name}
136 @r{[}@var{position}@r{]} @r{[}@var{arglist}@r{]}
138 @r{[}@var{documentation-string}@r{]}
139 @r{[}@var{interactive-form}@r{]}
144 Here, @var{function} is the name of the function (or macro or special
145 form) to be advised. From now on, we will write just ``function'' when
146 describing the entity being advised, but this always includes macros and
149 In place of the argument list in an ordinary definition, an advice
150 definition calls for several different pieces of information.
152 @cindex class of advice
153 @cindex before-advice
155 @cindex around-advice
156 @var{class} specifies the @dfn{class} of the advice---one of @code{before},
157 @code{after}, or @code{around}. Before-advice runs before the function
158 itself; after-advice runs after the function itself; around-advice is
159 wrapped around the execution of the function itself. After-advice and
160 around-advice can override the return value by setting
161 @code{ad-return-value}.
163 @defvar ad-return-value
164 While advice is executing, after the function's original definition has
165 been executed, this variable holds its return value, which will
166 ultimately be returned to the caller after finishing all the advice.
167 After-advice and around-advice can arrange to return some other value
168 by storing it in this variable.
171 The argument @var{name} is the name of the advice, a non-@code{nil}
172 symbol. The advice name uniquely identifies one piece of advice, within all
173 the pieces of advice in a particular class for a particular
174 @var{function}. The name allows you to refer to the piece of
175 advice---to redefine it, or to enable or disable it.
177 The optional @var{position} specifies where, in the current list of
178 advice of the specified @var{class}, this new advice should be placed.
179 It should be either @code{first}, @code{last} or a number that specifies
180 a zero-based position (@code{first} is equivalent to 0). If no position
181 is specified, the default is @code{first}. Position values outside the
182 range of existing positions in this class are mapped to the beginning or
183 the end of the range, whichever is closer. The @var{position} value is
184 ignored when redefining an existing piece of advice.
186 The optional @var{arglist} can be used to define the argument list for
187 the sake of advice. This becomes the argument list of the combined
188 definition that is generated in order to run the advice (@pxref{Combined
189 Definition}). Therefore, the advice expressions can use the argument
190 variables in this list to access argument values.
192 The argument list used in advice need not be the same as the argument
193 list used in the original function, but must be compatible with it, so
194 that it can handle the ways the function is actually called. If two
195 pieces of advice for a function both specify an argument list, they must
196 specify the same argument list.
198 @xref{Argument Access in Advice}, for more information about argument
199 lists and advice, and a more flexible way for advice to access the
202 The remaining elements, @var{flags}, are symbols that specify further
203 information about how to use this piece of advice. Here are the valid
204 symbols and their meanings:
208 Activate the advice for @var{function} now. Changes in a function's
209 advice always take effect the next time you activate advice for the
210 function; this flag says to do so, for @var{function}, immediately after
211 defining this piece of advice.
213 @cindex forward advice
214 This flag has no immediate effect if @var{function} itself is not defined yet (a
215 situation known as @dfn{forward advice}), because it is impossible to
216 activate an undefined function's advice. However, defining
217 @var{function} will automatically activate its advice.
220 Protect this piece of advice against non-local exits and errors in
221 preceding code and advice. Protecting advice places it as a cleanup in
222 an @code{unwind-protect} form, so that it will execute even if the
223 previous code gets an error or uses @code{throw}. @xref{Cleanups}.
226 Compile the combined definition that is used to run the advice. This
227 flag is ignored unless @code{activate} is also specified.
228 @xref{Combined Definition}.
231 Initially disable this piece of advice, so that it will not be used
232 unless subsequently explicitly enabled. @xref{Enabling Advice}.
235 Activate advice for @var{function} when this @code{defadvice} is
236 compiled or macroexpanded. This generates a compiled advised definition
237 according to the current advice state, which will be used during
238 activation if appropriate. @xref{Preactivation}.
240 This is useful only if this @code{defadvice} is byte-compiled.
243 The optional @var{documentation-string} serves to document this piece of
244 advice. When advice is active for @var{function}, the documentation for
245 @var{function} (as returned by @code{documentation}) combines the
246 documentation strings of all the advice for @var{function} with the
247 documentation string of its original function definition.
249 The optional @var{interactive-form} form can be supplied to change the
250 interactive behavior of the original function. If more than one piece
251 of advice has an @var{interactive-form}, then the first one (the one
252 with the smallest position) found among all the advice takes precedence.
254 The possibly empty list of @var{body-forms} specifies the body of the
255 advice. The body of an advice can access or change the arguments, the
256 return value, the binding environment, and perform any other kind of
259 @strong{Warning:} When you advise a macro, keep in mind that macros are
260 expanded when a program is compiled, not when a compiled program is run.
261 All subroutines used by the advice need to be available when the byte
262 compiler expands the macro.
264 @deffn Command ad-unadvise function
265 This command deletes all pieces of advice from @var{function}.
268 @deffn Command ad-unadvise-all
269 This command deletes all pieces of advice from all functions.
273 @section Around-Advice
275 Around-advice lets you ``wrap'' a Lisp expression ``around'' the
276 original function definition. You specify where the original function
277 definition should go by means of the special symbol @code{ad-do-it}.
278 Where this symbol occurs inside the around-advice body, it is replaced
279 with a @code{progn} containing the forms of the surrounded code. Here
283 (defadvice foo (around foo-around)
284 "Ignore case in `foo'."
285 (let ((case-fold-search t))
290 Its effect is to make sure that case is ignored in
291 searches when the original definition of @code{foo} is run.
294 This is not really a variable, rather a place-holder that looks like a
295 variable. You use it in around-advice to specify the place to run the
296 function's original definition and other ``earlier'' around-advice.
299 If the around-advice does not use @code{ad-do-it}, then it does not run
300 the original function definition. This provides a way to override the
301 original definition completely. (It also overrides lower-positioned
302 pieces of around-advice).
304 If the around-advice uses @code{ad-do-it} more than once, the original
305 definition is run at each place. In this way, around-advice can execute
306 the original definition (and lower-positioned pieces of around-advice)
307 several times. Another way to do that is by using @code{ad-do-it}
310 @node Computed Advice
311 @section Computed Advice
313 The macro @code{defadvice} resembles @code{defun} in that the code for
314 the advice, and all other information about it, are explicitly stated in
315 the source code. You can also create advice whose details are computed,
316 using the function @code{ad-add-advice}.
318 @defun ad-add-advice function advice class position
319 Calling @code{ad-add-advice} adds @var{advice} as a piece of advice to
320 @var{function} in class @var{class}. The argument @var{advice} has
324 (@var{name} @var{protected} @var{enabled} @var{definition})
328 Here, @var{protected} and @var{enabled} are flags; if @var{protected}
329 is non-@code{nil}, the advice is protected against non-local exits
330 (@pxref{Defining Advice}), and if @var{enabled} is @code{nil} the
331 advice is initially disabled (@pxref{Enabling Advice}).
332 @var{definition} should have the form
335 (advice . @var{lambda})
339 where @var{lambda} is a lambda expression; this lambda expression is
340 called in order to perform the advice. @xref{Lambda Expressions}.
342 If the @var{function} argument to @code{ad-add-advice} already has one
343 or more pieces of advice in the specified @var{class}, then
344 @var{position} specifies where in the list to put the new piece of
345 advice. The value of @var{position} can either be @code{first},
346 @code{last}, or a number (counting from 0 at the beginning of the
347 list). Numbers outside the range are mapped to the beginning or the
348 end of the range, whichever is closer. The @var{position} value is
349 ignored when redefining an existing piece of advice.
351 If @var{function} already has a piece of @var{advice} with the same
352 name, then the position argument is ignored and the old advice is
353 replaced with the new one.
356 @node Activation of Advice
357 @section Activation of Advice
358 @cindex activating advice
359 @cindex advice, activating
361 By default, advice does not take effect when you define it---only when
362 you @dfn{activate} advice for the function. However, the advice will
363 be activated automatically if you define or redefine the function
364 later. You can request the activation of advice for a function when
365 you define the advice, by specifying the @code{activate} flag in the
366 @code{defadvice}; or you can activate the advice separately by calling
367 the function @code{ad-activate} or one of the other activation
368 commands listed below.
370 Separating the activation of advice from the act of defining it permits
371 you to add several pieces of advice to one function efficiently, without
372 redefining the function over and over as each advice is added. More
373 importantly, it permits defining advice for a function before that
374 function is actually defined.
376 When a function's advice is first activated, the function's original
377 definition is saved, and all enabled pieces of advice for that function
378 are combined with the original definition to make a new definition.
379 (Pieces of advice that are currently disabled are not used; see
380 @ref{Enabling Advice}.) This definition is installed, and optionally
381 byte-compiled as well, depending on conditions described below.
383 In all of the commands to activate advice, if @var{compile} is
384 @code{t} (or anything but @code{nil} or a negative number), the
385 command also compiles the combined definition which implements the
386 advice. If it is @code{nil} or a negative number, what happens
387 depends on @code{ad-default-compilation-action} as described below.
389 @deffn Command ad-activate function &optional compile
390 This command activates all the advice defined for @var{function}.
393 Activating advice does nothing if @var{function}'s advice is already
394 active. But if there is new advice, added since the previous time you
395 activated advice for @var{function}, it activates the new advice.
397 @deffn Command ad-deactivate function
398 This command deactivates the advice for @var{function}.
399 @cindex deactivating advice
400 @c @cindex advice, deactivating "advice, activating" is just above
403 @deffn Command ad-update function &optional compile
404 This command activates the advice for @var{function}
405 if its advice is already activated. This is useful
406 if you change the advice.
409 @deffn Command ad-activate-all &optional compile
410 This command activates the advice for all functions.
413 @deffn Command ad-deactivate-all
414 This command deactivates the advice for all functions.
417 @deffn Command ad-update-all &optional compile
418 This command activates the advice for all functions
419 whose advice is already activated. This is useful
420 if you change the advice of some functions.
423 @deffn Command ad-activate-regexp regexp &optional compile
424 This command activates all pieces of advice whose names match
425 @var{regexp}. More precisely, it activates all advice for any function
426 which has at least one piece of advice that matches @var{regexp}.
429 @deffn Command ad-deactivate-regexp regexp
430 This command deactivates all pieces of advice whose names match
431 @var{regexp}. More precisely, it deactivates all advice for any
432 function which has at least one piece of advice that matches
436 @deffn Command ad-update-regexp regexp &optional compile
437 This command activates pieces of advice whose names match @var{regexp},
438 but only those for functions whose advice is already activated.
439 @cindex reactivating advice
441 Reactivating a function's advice is useful for putting into effect all
442 the changes that have been made in its advice (including enabling and
443 disabling specific pieces of advice; @pxref{Enabling Advice}) since the
444 last time it was activated.
447 @deffn Command ad-start-advice
448 Turn on automatic advice activation when a function is defined or
449 redefined. This is the default mode.
452 @deffn Command ad-stop-advice
453 Turn off automatic advice activation when a function is defined or
457 @defopt ad-default-compilation-action
458 This variable controls whether to compile the combined definition
459 that results from activating advice for a function.
461 A value of @code{always} specifies to compile unconditionally.
462 A value of @code{never} specifies never compile the advice.
464 A value of @code{maybe} specifies to compile if the byte compiler is
465 already loaded. A value of @code{like-original} specifies to compile
466 the advice if the original definition of the advised function is
467 compiled or a built-in function.
469 This variable takes effect only if the @var{compile} argument of
470 @code{ad-activate} (or any of the above functions) did not force
474 If the advised definition was constructed during ``preactivation''
475 (@pxref{Preactivation}), then that definition must already be compiled,
476 because it was constructed during byte-compilation of the file that
477 contained the @code{defadvice} with the @code{preactivate} flag.
479 @node Enabling Advice
480 @section Enabling and Disabling Advice
481 @cindex enabling advice
482 @cindex advice, enabling and disabling
483 @cindex disabling advice
485 Each piece of advice has a flag that says whether it is enabled or
486 not. By enabling or disabling a piece of advice, you can turn it on
487 and off without having to undefine and redefine it. For example, here is
488 how to disable a particular piece of advice named @code{my-advice} for
489 the function @code{foo}:
492 (ad-disable-advice 'foo 'before 'my-advice)
495 This function by itself only changes the enable flag for a piece of
496 advice. To make the change take effect in the advised definition, you
497 must activate the advice for @code{foo} again:
503 @deffn Command ad-disable-advice function class name
504 This command disables the piece of advice named @var{name} in class
505 @var{class} on @var{function}.
508 @deffn Command ad-enable-advice function class name
509 This command enables the piece of advice named @var{name} in class
510 @var{class} on @var{function}.
513 You can also disable many pieces of advice at once, for various
514 functions, using a regular expression. As always, the changes take real
515 effect only when you next reactivate advice for the functions in
518 @deffn Command ad-disable-regexp regexp
519 This command disables all pieces of advice whose names match
520 @var{regexp}, in all classes, on all functions.
523 @deffn Command ad-enable-regexp regexp
524 This command enables all pieces of advice whose names match
525 @var{regexp}, in all classes, on all functions.
529 @section Preactivation
530 @cindex preactivating advice
531 @cindex advice, preactivating
533 Constructing a combined definition to execute advice is moderately
534 expensive. When a library advises many functions, this can make loading
535 the library slow. In that case, you can use @dfn{preactivation} to
536 construct suitable combined definitions in advance.
538 To use preactivation, specify the @code{preactivate} flag when you
539 define the advice with @code{defadvice}. This @code{defadvice} call
540 creates a combined definition which embodies this piece of advice
541 (whether enabled or not) plus any other currently enabled advice for the
542 same function, and the function's own definition. If the
543 @code{defadvice} is compiled, that compiles the combined definition
546 When the function's advice is subsequently activated, if the enabled
547 advice for the function matches what was used to make this combined
548 definition, then the existing combined definition is used, thus avoiding
549 the need to construct one. Thus, preactivation never causes wrong
550 results---but it may fail to do any good, if the enabled advice at the
551 time of activation doesn't match what was used for preactivation.
553 Here are some symptoms that can indicate that a preactivation did not
554 work properly, because of a mismatch.
558 Activation of the advised
559 function takes longer than usual.
561 The byte compiler gets
562 loaded while an advised function gets activated.
564 @code{byte-compile} is included in the value of @code{features} even
565 though you did not ever explicitly use the byte compiler.
568 Compiled preactivated advice works properly even if the function itself
569 is not defined until later; however, the function needs to be defined
570 when you @emph{compile} the preactivated advice.
572 There is no elegant way to find out why preactivated advice is not being
573 used. What you can do is to trace the function
574 @code{ad-cache-id-verification-code} (with the function
575 @code{trace-function-background}) before the advised function's advice
576 is activated. After activation, check the value returned by
577 @code{ad-cache-id-verification-code} for that function: @code{verified}
578 means that the preactivated advice was used, while other values give
579 some information about why they were considered inappropriate.
581 @strong{Warning:} There is one known case that can make preactivation
582 fail, in that a preconstructed combined definition is used even though
583 it fails to match the current state of advice. This can happen when two
584 packages define different pieces of advice with the same name, in the
585 same class, for the same function. But you should avoid that anyway.
587 @node Argument Access in Advice
588 @section Argument Access in Advice
590 The simplest way to access the arguments of an advised function in the
591 body of a piece of advice is to use the same names that the function
592 definition uses. To do this, you need to know the names of the argument
593 variables of the original function.
595 While this simple method is sufficient in many cases, it has a
596 disadvantage: it is not robust, because it hard-codes the argument names
597 into the advice. If the definition of the original function changes,
598 the advice might break.
600 Another method is to specify an argument list in the advice itself.
601 This avoids the need to know the original function definition's argument
602 names, but it has a limitation: all the advice on any particular
603 function must use the same argument list, because the argument list
604 actually used for all the advice comes from the first piece of advice
607 A more robust method is to use macros that are translated into the
608 proper access forms at activation time, i.e., when constructing the
609 advised definition. Access macros access actual arguments by their
610 (zero-based) position, regardless of how these actual arguments get
611 distributed onto the argument variables of a function. This is robust
612 because in Emacs Lisp the meaning of an argument is strictly
613 determined by its position in the argument list.
615 @defmac ad-get-arg position
616 This returns the actual argument that was supplied at @var{position}.
619 @defmac ad-get-args position
620 This returns the list of actual arguments supplied starting at
624 @defmac ad-set-arg position value
625 This sets the value of the actual argument at @var{position} to
629 @defmac ad-set-args position value-list
630 This sets the list of actual arguments starting at @var{position} to
634 Now an example. Suppose the function @code{foo} is defined as
637 (defun foo (x y &optional z &rest r) ...)
641 and is then called with
648 which means that @var{x} is 0, @var{y} is 1, @var{z} is 2 and @var{r} is
649 @code{(3 4 5 6)} within the body of @code{foo}. Here is what
650 @code{ad-get-arg} and @code{ad-get-args} return in this case:
653 (ad-get-arg 0) @result{} 0
654 (ad-get-arg 1) @result{} 1
655 (ad-get-arg 2) @result{} 2
656 (ad-get-arg 3) @result{} 3
657 (ad-get-args 2) @result{} (2 3 4 5 6)
658 (ad-get-args 4) @result{} (4 5 6)
661 Setting arguments also makes sense in this example:
664 (ad-set-arg 5 "five")
668 has the effect of changing the sixth argument to @code{"five"}. If this
669 happens in advice executed before the body of @code{foo} is run, then
670 @var{r} will be @code{(3 4 "five" 6)} within that body.
672 Here is an example of setting a tail of the argument list:
675 (ad-set-args 0 '(5 4 3 2 1 0))
679 If this happens in advice executed before the body of @code{foo} is run,
680 then within that body, @var{x} will be 5, @var{y} will be 4, @var{z}
681 will be 3, and @var{r} will be @code{(2 1 0)} inside the body of
684 These argument constructs are not really implemented as Lisp macros.
685 Instead they are implemented specially by the advice mechanism.
687 @node Combined Definition
688 @section The Combined Definition
690 Suppose that a function has @var{n} pieces of before-advice
691 (numbered from 0 through @var{n}@minus{}1), @var{m} pieces of
692 around-advice and @var{k} pieces of after-advice. Assuming no piece
693 of advice is protected, the combined definition produced to implement
694 the advice for a function looks like this:
697 (lambda @var{arglist}
698 @r{[} @r{[}@var{advised-docstring}@r{]} @r{[}(interactive ...)@r{]} @r{]}
699 (let (ad-return-value)
700 @r{before-0-body-form}...
702 @r{before-@var{n}@minus{}1-body-form}...
703 @r{around-0-body-form}...
704 @r{around-1-body-form}...
706 @r{around-@var{m}@minus{}1-body-form}...
707 (setq ad-return-value
708 @r{apply original definition to @var{arglist}})
709 @r{end-of-around-@var{m}@minus{}1-body-form}...
711 @r{end-of-around-1-body-form}...
712 @r{end-of-around-0-body-form}...
713 @r{after-0-body-form}...
715 @r{after-@var{k}@minus{}1-body-form}...
719 Macros are redefined as macros, which means adding @code{macro} to
720 the beginning of the combined definition.
722 The interactive form is present if the original function or some piece
723 of advice specifies one. When an interactive primitive function is
724 advised, advice uses a special method: it calls the primitive with
725 @code{call-interactively} so that it will read its own arguments.
726 In this case, the advice cannot access the arguments.
728 The body forms of the various advice in each class are assembled
729 according to their specified order. The forms of around-advice @var{l}
730 are included in one of the forms of around-advice @var{l} @minus{} 1.
732 The innermost part of the around advice onion is
735 apply original definition to @var{arglist}
739 whose form depends on the type of the original function. The variable
740 @code{ad-return-value} is set to whatever this returns. The variable is
741 visible to all pieces of advice, which can access and modify it before
742 it is actually returned from the advised function.
744 The semantic structure of advised functions that contain protected
745 pieces of advice is the same. The only difference is that
746 @code{unwind-protect} forms ensure that the protected advice gets
747 executed even if some previous piece of advice had an error or a
748 non-local exit. If any around-advice is protected, then the whole
749 around-advice onion is protected as a result.