• Richard M. Stallman's avatar
    New handling of automatic advice activation that · fabaa9b5
    Richard M. Stallman authored
    exploits modified built-in versions of `fset' and `defalias' which
    take care of this functionality directly:
    (ad-start-advice-on-load, ad-activate-on-definition)
    (ad-definition-hooks, ad-enable-definition-hooks, ad-defined-function)
    (ad-advised-definers, ad-advised-byte-compilers, byte-constant)
    (byte-constant-limit, byte-constant2, byte-fset)
    (ad-byte-code-fset-regexp): Variables deleted.
    (ad-activate-defined-function, ad-find-fset-in-byte-code)
    (ad-scan-byte-code-for-fsets, ad-advised-byte-code)
    (ad-recover-byte-code, ad-enable-definition-hooks)
    (ad-disable-definition-hooks): Functions deleted.
    (defun, defmacro, fset, defalias, define-function)
    (byte-compile-from-buffer, byte-compile-top-level): Removed `defadvice'
    for these functions.
    (ad-save-real-definitions): Removed saving of `byte-code'.
    (ad-activate-off): New dummy function.
    (ad-activate-on): New name for `ad-activate'.  All calls changed.
    (ad-with-auto-activation-disabled): New macro prevents automatic
    advice activation.
    (ad-safe-fset): New function, used instead of `ad-real-fset'.
    (ad-compile-function): Disable automatic advice activation while
    compiling, because `byte-compile' uses `fset'.
    (ad-activate-on): Renamed from `ad-activate'.  Avoid recursive calls.
    (ad-activate-on-top-level): New variable.
    (ad-start-advice, ad-stop-advice, ad-recover-normality): Modified to
    achieve de/activation of automatic advice activation by setting the
    definition of `ad-activate' to `ad-activate-on' or `ad-activate-off'.
    (ad-start-advice): Is now called unconditionally when Advice is loaded.
    
    Made compilation behavior of advised definitions customizable, since
    loading the byte-compiler takes some time and is not always worth the
    cost, e.g., if one only wants to make a few simple modifications:
    (ad-default-compilation-action): New variable which specifies whether
    to compile an advised definition in case the COMPILE argument to
    `ad-activate-on' or one of its friends was supplied as nil.
    (ad-preactivate-advice): Supply negative COMPILE argument to prevent
    compilation.
    (ad-should-compile): New function.
    (ad-activate-advised-definition): Use `ad-should-compile' to determine
    whether an advised definition should get compiled.
    (ad-activate-on, ad-update, ad-activate-regexp, ad-update-regexp)
    (ad-activate-all): Doc fixes.
    (ad-update): Leave handling of COMPILE up to `ad-activate-on'.
    
    Extracted construction of freeze-advices from `defadvice':
    (ad-make-freeze-definition): New function.
    (defadvice): Use `ad-make-freeze-definition' to construct frozen defs.
    fabaa9b5
advice.el 165 KB