diff options
| author | Richard M. Stallman | 1994-02-25 00:57:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-02-25 00:57:37 +0000 |
| commit | f643a89157e34c9ecba78165a1e9b795181c97f3 (patch) | |
| tree | e6f6d77635b16bd3286bcb35b36875f30a1b6369 | |
| parent | d9e42bcf3664f56652bcc5660f7eb869c755c6f0 (diff) | |
| download | emacs-f643a89157e34c9ecba78165a1e9b795181c97f3.tar.gz emacs-f643a89157e34c9ecba78165a1e9b795181c97f3.zip | |
(byte-compile-from-buffer, byte-compile-top-level):
Removed advice. Byte-compilation problem is now taken care of
directly by the compiler.
(ad-advised-byte-compilers): Removed.
(ad-enable-definition-hooks, ad-disable-definition-hooks): Removed
activation of the advised byte-compiler entry points.
(ad-lemacs-p): Removed variable.
(ad-lemacs-p): New macro for compile-time conditionalization.
| -rw-r--r-- | lisp/emacs-lisp/advice.el | 136 |
1 files changed, 28 insertions, 108 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index 7d400842850..18c52aab943 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Hans Chalupsky <hans@cs.buffalo.edu> | 5 | ;; Author: Hans Chalupsky <hans@cs.buffalo.edu> |
| 6 | ;; Created: 12 Dec 1992 | 6 | ;; Created: 12 Dec 1992 |
| 7 | ;; Version: advice.el,v 2.10 1994/02/21 10:34:03 hans Exp | 7 | ;; Version: advice.el,v 2.11 1994/02/24 22:51:43 hans Exp |
| 8 | ;; Keywords: extensions, lisp, tools | 8 | ;; Keywords: extensions, lisp, tools |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -26,7 +26,7 @@ | |||
| 26 | ;; LCD Archive Entry: | 26 | ;; LCD Archive Entry: |
| 27 | ;; advice|Hans Chalupsky|hans@cs.buffalo.edu| | 27 | ;; advice|Hans Chalupsky|hans@cs.buffalo.edu| |
| 28 | ;; Overloading mechanism for Emacs Lisp functions| | 28 | ;; Overloading mechanism for Emacs Lisp functions| |
| 29 | ;; 1994/02/21 10:34:03|2.10|~/packages/advice.el.Z| | 29 | ;; 1994/02/24 22:51:43|2.11|~/packages/advice.el.Z| |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | ;;; Commentary: | 32 | ;;; Commentary: |
| @@ -1938,98 +1938,6 @@ | |||
| 1938 | ;; from advising plain functions or subrs. | 1938 | ;; from advising plain functions or subrs. |
| 1939 | 1939 | ||
| 1940 | 1940 | ||
| 1941 | ;;; Change Log: | ||
| 1942 | |||
| 1943 | ;; advice.el,v | ||
| 1944 | ;; Revision 2.10 1994/02/21 10:34:03 hans | ||
| 1945 | ;; * Removed all support for Emacs-18 and associated conditional code. | ||
| 1946 | ;; * Made some minor changes to the documentation which is now | ||
| 1947 | ;; slightly out-of-date. | ||
| 1948 | ;; | ||
| 1949 | ;; Revision 2.9 1994/02/21 08:03:39 hans | ||
| 1950 | ;; * Lots of cosmetic changes to make documentation strings | ||
| 1951 | ;; conform to the standard conventions. | ||
| 1952 | ;; * Some minor changes to the general documentation. | ||
| 1953 | ;; * This version is the last one that still supports a v18 Emacs. | ||
| 1954 | ;; It will be made available as `advice18.el'. | ||
| 1955 | ;; | ||
| 1956 | ;; Revision 2.8 1994/02/20 01:46:02 hans | ||
| 1957 | ;; * (ad-enable-definition-hooks): Disabled definition hooks for | ||
| 1958 | ;; the combination of a v18 Emacs with a v19 byte-compiler, | ||
| 1959 | ;; because it breaks the rather important `interactive-p'. | ||
| 1960 | ;; | ||
| 1961 | ;; Revision 2.7 1994/02/20 01:09:18 hans | ||
| 1962 | ;; * Fixed the problematic interaction between the byte-compiler and | ||
| 1963 | ;; Advice when `ad-activate-on-definition' was t which | ||
| 1964 | ;; resulted in erroneous compilation of nested `defun/defmacro's: | ||
| 1965 | ;; * (byte-compile-from-buffer, byte-compile-top-level): Now | ||
| 1966 | ;; advised to temporarily deactivate the advice of `defun/defmacro'. | ||
| 1967 | ;; * (ad-advised-definers, ad-advised-byte-compilers): New variables. | ||
| 1968 | ;; * (ad-execute-defadvices): Contains the new advices for the | ||
| 1969 | ;; byte-compiler entry points. Uses new variables to copy advice infos. | ||
| 1970 | ;; * (ad-enable-definition-hooks, ad-disable-definition-hooks): | ||
| 1971 | ;; Additionally en/disable the advised byte-compiler entry | ||
| 1972 | ;; points. Uses new variables to do so. | ||
| 1973 | ;; | ||
| 1974 | ;; Revision 2.6 1994/02/18 11:02:00 hans | ||
| 1975 | ;; * (defadvice): Implement jwz's idea of a `freeze' option which | ||
| 1976 | ;; expands the `defadvice' into a dumpable `defun/defmacro' | ||
| 1977 | ;; whose documentation can be written to the `DOC' file. | ||
| 1978 | ;; * (ad-make-advised-docstring, ad-make-single-advice-docstring): | ||
| 1979 | ;; New STYLE option for `plain' and `freeze' styles. Slightly | ||
| 1980 | ;; changed the default formatting of advised docstrings. | ||
| 1981 | ;; * (ad-make-plain-docstring, ad-make-freeze-docstring): New functions. | ||
| 1982 | ;; | ||
| 1983 | ;; Revision 2.5 1994/02/18 06:52:25 hans | ||
| 1984 | ;; * Merged with version of Lemacs 19.9: Infinite recursion bug in jwz's | ||
| 1985 | ;; adaption of `ad-docstring' fixed with use of `ad-real-documentation'. | ||
| 1986 | ;; * (ad-recover-all, ad-scan-byte-code-for-fsets): Removed | ||
| 1987 | ;; unused condition variable `ignore-errors'. | ||
| 1988 | ;; | ||
| 1989 | ;; Revision 2.4 1994/02/18 06:01:56 hans | ||
| 1990 | ;; * (ad-save-real-definition): New macro to save real | ||
| 1991 | ;; definitions of functions used by Advice with all the | ||
| 1992 | ;; necessary byte-compile properties. | ||
| 1993 | ;; * Now also save real definition of `documentation'. | ||
| 1994 | ;; * (ad-subr-arglist, ad-docstring, ad-make-advised-docstring): | ||
| 1995 | ;; Use `ad-real-documentation' to avoid interference with | ||
| 1996 | ;; advised version. | ||
| 1997 | ;; | ||
| 1998 | ;; Revision 2.3 1994/01/25 05:25:00 hans | ||
| 1999 | ;; * (ad-execute-defadvices): Copy advice infos to make sure they | ||
| 2000 | ;; are not allocated in pure space during preloading (otherwise | ||
| 2001 | ;; we cannot modify them later on). | ||
| 2002 | ;; | ||
| 2003 | ;; Revision 2.2 1993/12/23 02:32:34 hans | ||
| 2004 | ;; * Merged with the version of the Emacs 19.22 distribution: | ||
| 2005 | ;; (ad-start-advice-on-load): Default is now t. | ||
| 2006 | ;; New value for `Keywords' header specification. | ||
| 2007 | ;; | ||
| 2008 | ;; Revision 2.1 1993/05/26 00:07:58 hans | ||
| 2009 | ;; * advise `defalias' and `define-function' to properly handle forward | ||
| 2010 | ;; advice in Emacs-19.7 and later | ||
| 2011 | ;; * fix minor bug in `ad-preactivate-advice' | ||
| 2012 | ;; * merge with FSF installation of version 2.0 | ||
| 2013 | ;; | ||
| 2014 | ;; Revision 2.0 1993/05/18 01:29:02 hans | ||
| 2015 | ;; * Totally revamped: Now also works with v19s, function indirection | ||
| 2016 | ;; instead of body copying for original function calls, caching of | ||
| 2017 | ;; advised definitions, en/disable mechanism, more and better | ||
| 2018 | ;; interactive functions, forward advice support for jwz's compiler, | ||
| 2019 | ;; definition hooks, portable argument access, argument list definition | ||
| 2020 | ;; for advised functions, preactivation mechanism, pretty comprehensive | ||
| 2021 | ;; docs (still no info file) | ||
| 2022 | ;; | ||
| 2023 | ;; Revision 1.8 1992/12/15 22:54:45 hans | ||
| 2024 | ;; * Replaced non-standard `member' with `memq'. | ||
| 2025 | ;; | ||
| 2026 | ;; Revision 1.7 1992/12/14 22:41:49 hans | ||
| 2027 | ;; * First publicly released version | ||
| 2028 | ;; | ||
| 2029 | ;; Revision 1.1 1992/12/12 05:37:33 hans | ||
| 2030 | ;; * Created | ||
| 2031 | |||
| 2032 | |||
| 2033 | ;;; Code: | 1941 | ;;; Code: |
| 2034 | 1942 | ||
| 2035 | ;; @ Advice implementation: | 1943 | ;; @ Advice implementation: |
| @@ -2049,11 +1957,12 @@ | |||
| 2049 | ;; @@ Variable definitions: | 1957 | ;; @@ Variable definitions: |
| 2050 | ;; ======================== | 1958 | ;; ======================== |
| 2051 | 1959 | ||
| 2052 | (defconst ad-version "2.10") | 1960 | (defconst ad-version "2.11") |
| 2053 | 1961 | ||
| 2054 | (defconst ad-lemacs-p | 1962 | (defmacro ad-lemacs-p () |
| 2055 | (string-match "Lucid" emacs-version) | 1963 | ;;Expands into Non-nil constant if we run Lucid's version of Emacs-19. |
| 2056 | "Non-nil if we run Lucid's version of Emacs-19.") | 1964 | ;;Unselected conditional code will be optimized away during compilation. |
| 1965 | (string-match "Lucid" emacs-version)) | ||
| 2057 | 1966 | ||
| 2058 | ;;;###autoload | 1967 | ;;;###autoload |
| 2059 | (defvar ad-start-advice-on-load t | 1968 | (defvar ad-start-advice-on-load t |
| @@ -4012,8 +3921,6 @@ definition will be compiled too. FUNCTION defaults to the value of | |||
| 4012 | 3921 | ||
| 4013 | (defvar ad-advised-definers | 3922 | (defvar ad-advised-definers |
| 4014 | '(defun defmacro fset defalias define-function)) | 3923 | '(defun defmacro fset defalias define-function)) |
| 4015 | (defvar ad-advised-byte-compilers | ||
| 4016 | '(byte-compile-from-buffer byte-compile-top-level)) | ||
| 4017 | 3924 | ||
| 4018 | (defadvice defun (after ad-definition-hooks first disable preact) | 3925 | (defadvice defun (after ad-definition-hooks first disable preact) |
| 4019 | "Whenever a function gets re/defined with `defun' all hook functions | 3926 | "Whenever a function gets re/defined with `defun' all hook functions |
| @@ -4089,7 +3996,14 @@ functions in `ad-definition-hooks' will be run after the re/definition with | |||
| 4089 | ;; Both advices are forward advices, hence, they will only be activated if | 3996 | ;; Both advices are forward advices, hence, they will only be activated if |
| 4090 | ;; automatic advice activation is enabled, but since that is the actual | 3997 | ;; automatic advice activation is enabled, but since that is the actual |
| 4091 | ;; situation where we have a problem, we can be sure that the advices will | 3998 | ;; situation where we have a problem, we can be sure that the advices will |
| 4092 | ;; be active when we need it. | 3999 | ;; be active when we need them. |
| 4000 | |||
| 4001 | ;; We only need this in Lemacs, because in Emacs it is | ||
| 4002 | ;; now taken care of directly by the byte-compiler: | ||
| 4003 | (cond ((ad-lemacs-p) | ||
| 4004 | |||
| 4005 | (defvar ad-advised-byte-compilers | ||
| 4006 | '(byte-compile-from-buffer byte-compile-top-level)) | ||
| 4093 | 4007 | ||
| 4094 | (defadvice byte-compile-from-buffer (around ad-deactivate-defun-defmacro | 4008 | (defadvice byte-compile-from-buffer (around ad-deactivate-defun-defmacro |
| 4095 | first disable preact) | 4009 | first disable preact) |
| @@ -4107,11 +4021,14 @@ functions in `ad-definition-hooks' will be run after the re/definition with | |||
| 4107 | (ad-with-originals (defun defmacro) | 4021 | (ad-with-originals (defun defmacro) |
| 4108 | ad-do-it))) | 4022 | ad-do-it))) |
| 4109 | 4023 | ||
| 4024 | )) ;; end of cond | ||
| 4025 | |||
| 4110 | ;; Make sure advice-infos are not allocated in pure space | 4026 | ;; Make sure advice-infos are not allocated in pure space |
| 4111 | ;; (this might not be necessary anymore): | 4027 | ;; (this might not be necessary anymore): |
| 4112 | (ad-dolist (advised-function (cons 'documentation | 4028 | (ad-dolist (advised-function (cons 'documentation |
| 4113 | (append ad-advised-definers | 4029 | (append ad-advised-definers |
| 4114 | ad-advised-byte-compilers))) | 4030 | (if (ad-lemacs-p) |
| 4031 | ad-advised-byte-compilers)))) | ||
| 4115 | (ad-set-advice-info advised-function (ad-copy-advice-info advised-function))) | 4032 | (ad-set-advice-info advised-function (ad-copy-advice-info advised-function))) |
| 4116 | 4033 | ||
| 4117 | 4034 | ||
| @@ -4266,9 +4183,10 @@ See `ad-real-byte-code' for original documentation." | |||
| 4266 | (ad-dolist (definer ad-advised-definers) | 4183 | (ad-dolist (definer ad-advised-definers) |
| 4267 | (ad-enable-advice definer 'after 'ad-definition-hooks) | 4184 | (ad-enable-advice definer 'after 'ad-definition-hooks) |
| 4268 | (ad-activate definer 'compile)) | 4185 | (ad-activate definer 'compile)) |
| 4269 | (ad-dolist (byte-compiler ad-advised-byte-compilers) | 4186 | (if (ad-lemacs-p) |
| 4270 | (ad-enable-advice byte-compiler 'around 'ad-deactivate-defun-defmacro) | 4187 | (ad-dolist (byte-compiler ad-advised-byte-compilers) |
| 4271 | (ad-activate byte-compiler 'compile)) | 4188 | (ad-enable-advice byte-compiler 'around 'ad-deactivate-defun-defmacro) |
| 4189 | (ad-activate byte-compiler 'compile))) | ||
| 4272 | ;; Now redefine byte-code... | 4190 | ;; Now redefine byte-code... |
| 4273 | (ad-real-fset 'byte-code (symbol-function 'ad-advised-byte-code))) | 4191 | (ad-real-fset 'byte-code (symbol-function 'ad-advised-byte-code))) |
| 4274 | 4192 | ||
| @@ -4278,9 +4196,10 @@ See `ad-real-byte-code' for original documentation." | |||
| 4278 | (ad-dolist (definer ad-advised-definers) | 4196 | (ad-dolist (definer ad-advised-definers) |
| 4279 | (ad-disable-advice definer 'after 'ad-definition-hooks) | 4197 | (ad-disable-advice definer 'after 'ad-definition-hooks) |
| 4280 | (ad-update definer)) | 4198 | (ad-update definer)) |
| 4281 | (ad-dolist (byte-compiler ad-advised-byte-compilers) | 4199 | (if (ad-lemacs-p) |
| 4282 | (ad-disable-advice byte-compiler 'around 'ad-deactivate-defun-defmacro) | 4200 | (ad-dolist (byte-compiler ad-advised-byte-compilers) |
| 4283 | (ad-update byte-compiler 'compile))) | 4201 | (ad-disable-advice byte-compiler 'around 'ad-deactivate-defun-defmacro) |
| 4202 | (ad-update byte-compiler 'compile)))) | ||
| 4284 | 4203 | ||
| 4285 | 4204 | ||
| 4286 | ;; @@ Starting, stopping and recovering from the advice package magic: | 4205 | ;; @@ Starting, stopping and recovering from the advice package magic: |
| @@ -4339,3 +4258,4 @@ Use only in REAL emergencies." | |||
| 4339 | (provide 'advice) | 4258 | (provide 'advice) |
| 4340 | 4259 | ||
| 4341 | ;;; advice.el ends here | 4260 | ;;; advice.el ends here |
| 4261 | |||