diff options
| author | Stefan Monnier | 2012-11-09 15:41:03 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2012-11-09 15:41:03 -0500 |
| commit | 6858633a9c9f7e764e017cc5cbf77516729d120b (patch) | |
| tree | 0cb9c6cb674b20aad9fa50b815ea9a2e88d3439a /lisp | |
| parent | 4ab15c3ec6aae154f9a926e47527bf837615c670 (diff) | |
| download | emacs-6858633a9c9f7e764e017cc5cbf77516729d120b.tar.gz emacs-6858633a9c9f7e764e017cc5cbf77516729d120b.zip | |
* lisp/emacs-lisp/advice.el: Miscellaneous cleanup. Use lexical-binding.
(fset, documentation): Don't save real def since we don't advise.
(ad-do-advised-functions): Remove problematic `result-form'.
(ad-safe-fset): `ad-real-fset' => `fset'.
(ad-read-advised-function): Don't assume that ad-do-advised-functions
uses CL's dolist internally.
(ad-arglist): Remove unused arg `name'.
(ad-docstring, ad-make-advised-docstring):
`ad-real-documentation' => `documentation'.
(warning-suppress-types): Declare.
(ad-set-arguments): Simple CSE.
(ad-recover-normality): Sanity check.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/advice.el | 157 |
2 files changed, 80 insertions, 90 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a7f6d1befb5..612cdc33d52 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2012-11-09 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-11-09 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/advice.el: Miscellaneous cleanup. Use lexical-binding. | ||
| 4 | (fset, documentation): Don't save real def since we don't advise. | ||
| 5 | (ad-do-advised-functions): Remove problematic `result-form'. | ||
| 6 | (ad-safe-fset): `ad-real-fset' => `fset'. | ||
| 7 | (ad-read-advised-function): Don't assume that ad-do-advised-functions | ||
| 8 | uses CL's dolist internally. | ||
| 9 | (ad-arglist): Remove unused arg `name'. | ||
| 10 | (ad-docstring, ad-make-advised-docstring): | ||
| 11 | `ad-real-documentation' => `documentation'. | ||
| 12 | (warning-suppress-types): Declare. | ||
| 13 | (ad-set-arguments): Simple CSE. | ||
| 14 | (ad-recover-normality): Sanity check. | ||
| 15 | |||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-out-toplevel): Don't turn | 16 | * emacs-lisp/bytecomp.el (byte-compile-out-toplevel): Don't turn |
| 4 | (funcall '(lambda ..) ..) into ((lambda ..) ..). | 17 | (funcall '(lambda ..) ..) into ((lambda ..) ..). |
| 5 | 18 | ||
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index 33805836db2..92becb8bea9 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; advice.el --- An overloading mechanism for Emacs Lisp functions | 1 | ;;; advice.el --- An overloading mechanism for Emacs Lisp functions -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1993-1994, 2000-2012 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1993-1994, 2000-2012 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -1795,15 +1795,6 @@ generates a copy of TREE." | |||
| 1795 | `((put ',saved-function 'byte-opcode | 1795 | `((put ',saved-function 'byte-opcode |
| 1796 | ',(get function 'byte-opcode)))))))) | 1796 | ',(get function 'byte-opcode)))))))) |
| 1797 | 1797 | ||
| 1798 | (defun ad-save-real-definitions () | ||
| 1799 | ;; Macro expansion will hardcode the values of the various byte-compiler | ||
| 1800 | ;; properties into the compiled version of this function such that the | ||
| 1801 | ;; proper values will be available at runtime without loading the compiler: | ||
| 1802 | (ad-save-real-definition fset) | ||
| 1803 | (ad-save-real-definition documentation)) | ||
| 1804 | |||
| 1805 | (ad-save-real-definitions) | ||
| 1806 | |||
| 1807 | 1798 | ||
| 1808 | ;; @@ Advice info access fns: | 1799 | ;; @@ Advice info access fns: |
| 1809 | ;; ========================== | 1800 | ;; ========================== |
| @@ -1839,15 +1830,13 @@ generates a copy of TREE." | |||
| 1839 | ad-advised-functions))) | 1830 | ad-advised-functions))) |
| 1840 | 1831 | ||
| 1841 | (defmacro ad-do-advised-functions (varform &rest body) | 1832 | (defmacro ad-do-advised-functions (varform &rest body) |
| 1842 | "`dolist'-style iterator that maps over `ad-advised-functions'. | 1833 | "`dolist'-style iterator that maps over advised functions. |
| 1843 | \(ad-do-advised-functions (VAR [RESULT-FORM]) | 1834 | \(ad-do-advised-functions (VAR) |
| 1844 | BODY-FORM...) | 1835 | BODY-FORM...) |
| 1845 | On each iteration VAR will be bound to the name of an advised function | 1836 | On each iteration VAR will be bound to the name of an advised function |
| 1846 | \(a symbol)." | 1837 | \(a symbol)." |
| 1847 | (declare (indent 1)) | 1838 | (declare (indent 1)) |
| 1848 | `(cl-dolist (,(car varform) | 1839 | `(cl-dolist (,(car varform) ad-advised-functions) |
| 1849 | ad-advised-functions | ||
| 1850 | ,(car (cdr varform))) | ||
| 1851 | (setq ,(car varform) (intern (car ,(car varform)))) | 1840 | (setq ,(car varform) (intern (car ,(car varform)))) |
| 1852 | ,@body)) | 1841 | ,@body)) |
| 1853 | 1842 | ||
| @@ -1866,7 +1855,7 @@ On each iteration VAR will be bound to the name of an advised function | |||
| 1866 | (defmacro ad-is-advised (function) | 1855 | (defmacro ad-is-advised (function) |
| 1867 | "Return non-nil if FUNCTION has any advice info associated with it. | 1856 | "Return non-nil if FUNCTION has any advice info associated with it. |
| 1868 | This does not mean that the advice is also active." | 1857 | This does not mean that the advice is also active." |
| 1869 | (list 'ad-get-advice-info-macro function)) | 1858 | `(ad-get-advice-info-macro ,function)) |
| 1870 | 1859 | ||
| 1871 | (defun ad-initialize-advice-info (function) | 1860 | (defun ad-initialize-advice-info (function) |
| 1872 | "Initialize the advice info for FUNCTION. | 1861 | "Initialize the advice info for FUNCTION. |
| @@ -1949,7 +1938,7 @@ Redefining advices affect the construction of an advised definition." | |||
| 1949 | (defun ad-has-any-advice (function) | 1938 | (defun ad-has-any-advice (function) |
| 1950 | "True if the advice info of FUNCTION defines at least one advice." | 1939 | "True if the advice info of FUNCTION defines at least one advice." |
| 1951 | (and (ad-is-advised function) | 1940 | (and (ad-is-advised function) |
| 1952 | (cl-dolist (class ad-advice-classes nil) | 1941 | (cl-dolist (class ad-advice-classes) |
| 1953 | (if (ad-get-advice-info-field function class) | 1942 | (if (ad-get-advice-info-field function class) |
| 1954 | (cl-return t))))) | 1943 | (cl-return t))))) |
| 1955 | 1944 | ||
| @@ -1989,12 +1978,12 @@ Redefining advices affect the construction of an advised definition." | |||
| 1989 | ;; appropriate, especially in a safe version of `fset'. | 1978 | ;; appropriate, especially in a safe version of `fset'. |
| 1990 | 1979 | ||
| 1991 | ;; For now define `ad-activate-internal' to the dummy definition: | 1980 | ;; For now define `ad-activate-internal' to the dummy definition: |
| 1992 | (defun ad-activate-internal (function &optional compile) | 1981 | (defun ad-activate-internal (_function &optional _compile) |
| 1993 | "Automatic advice activation is disabled. `ad-start-advice' enables it." | 1982 | "Automatic advice activation is disabled. `ad-start-advice' enables it." |
| 1994 | nil) | 1983 | nil) |
| 1995 | 1984 | ||
| 1996 | ;; This is just a copy of the above: | 1985 | ;; This is just a copy of the above: |
| 1997 | (defun ad-activate-internal-off (function &optional compile) | 1986 | (defun ad-activate-internal-off (_function &optional _compile) |
| 1998 | "Automatic advice activation is disabled. `ad-start-advice' enables it." | 1987 | "Automatic advice activation is disabled. `ad-start-advice' enables it." |
| 1999 | nil) | 1988 | nil) |
| 2000 | 1989 | ||
| @@ -2008,7 +1997,7 @@ Redefining advices affect the construction of an advised definition." | |||
| 2008 | (defun ad-safe-fset (symbol definition) | 1997 | (defun ad-safe-fset (symbol definition) |
| 2009 | "A safe `fset' which will never call `ad-activate-internal' recursively." | 1998 | "A safe `fset' which will never call `ad-activate-internal' recursively." |
| 2010 | (ad-with-auto-activation-disabled | 1999 | (ad-with-auto-activation-disabled |
| 2011 | (ad-real-fset symbol definition))) | 2000 | (fset symbol definition))) |
| 2012 | 2001 | ||
| 2013 | 2002 | ||
| 2014 | ;; @@ Access functions for original definitions: | 2003 | ;; @@ Access functions for original definitions: |
| @@ -2052,7 +2041,7 @@ function at point for which PREDICATE returns non-nil)." | |||
| 2052 | (error "ad-read-advised-function: There are no advised functions")) | 2041 | (error "ad-read-advised-function: There are no advised functions")) |
| 2053 | (setq default | 2042 | (setq default |
| 2054 | (or default | 2043 | (or default |
| 2055 | ;; Prefer func name at point, if it's in ad-advised-functions etc. | 2044 | ;; Prefer func name at point, if it's an advised function etc. |
| 2056 | (let ((function (progn | 2045 | (let ((function (progn |
| 2057 | (require 'help) | 2046 | (require 'help) |
| 2058 | (function-called-at-point)))) | 2047 | (function-called-at-point)))) |
| @@ -2061,24 +2050,20 @@ function at point for which PREDICATE returns non-nil)." | |||
| 2061 | (or (null predicate) | 2050 | (or (null predicate) |
| 2062 | (funcall predicate function)) | 2051 | (funcall predicate function)) |
| 2063 | function)) | 2052 | function)) |
| 2064 | (ad-do-advised-functions (function) | 2053 | (cl-block nil |
| 2065 | (if (or (null predicate) | 2054 | (ad-do-advised-functions (function) |
| 2066 | (funcall predicate function)) | 2055 | (if (or (null predicate) |
| 2067 | (cl-return function))) | 2056 | (funcall predicate function)) |
| 2057 | (cl-return function)))) | ||
| 2068 | (error "ad-read-advised-function: %s" | 2058 | (error "ad-read-advised-function: %s" |
| 2069 | "There are no qualifying advised functions"))) | 2059 | "There are no qualifying advised functions"))) |
| 2070 | (let* ((ad-pReDiCaTe predicate) | 2060 | (let* ((function |
| 2071 | (function | ||
| 2072 | (completing-read | 2061 | (completing-read |
| 2073 | (format "%s (default %s): " (or prompt "Function") default) | 2062 | (format "%s (default %s): " (or prompt "Function") default) |
| 2074 | ad-advised-functions | 2063 | ad-advised-functions |
| 2075 | (if predicate | 2064 | (if predicate |
| 2076 | (function | 2065 | (lambda (function) |
| 2077 | (lambda (function) | 2066 | (funcall predicate (intern (car function))))) |
| 2078 | ;; Oops, no closures - the joys of dynamic scoping: | ||
| 2079 | ;; `predicate' clashed with the `predicate' argument | ||
| 2080 | ;; of `completing-read'..... | ||
| 2081 | (funcall ad-pReDiCaTe (intern (car function)))))) | ||
| 2082 | t))) | 2067 | t))) |
| 2083 | (if (equal function "") | 2068 | (if (equal function "") |
| 2084 | (if (ad-is-advised default) | 2069 | (if (ad-is-advised default) |
| @@ -2376,10 +2361,8 @@ See Info node `(elisp)Computed Advice' for detailed documentation." | |||
| 2376 | (cdr definition)) | 2361 | (cdr definition)) |
| 2377 | (t nil))) | 2362 | (t nil))) |
| 2378 | 2363 | ||
| 2379 | (defun ad-arglist (definition &optional name) | 2364 | (defun ad-arglist (definition) |
| 2380 | "Return the argument list of DEFINITION. | 2365 | "Return the argument list of DEFINITION." |
| 2381 | If DEFINITION could be from a subr then its NAME should be | ||
| 2382 | supplied to make subr arglist lookup more efficient." | ||
| 2383 | (require 'help-fns) | 2366 | (require 'help-fns) |
| 2384 | (help-function-arglist | 2367 | (help-function-arglist |
| 2385 | (if (or (ad-macro-p definition) (ad-advice-p definition)) | 2368 | (if (or (ad-macro-p definition) (ad-advice-p definition)) |
| @@ -2391,7 +2374,7 @@ supplied to make subr arglist lookup more efficient." | |||
| 2391 | "Return the unexpanded docstring of DEFINITION." | 2374 | "Return the unexpanded docstring of DEFINITION." |
| 2392 | (let ((docstring | 2375 | (let ((docstring |
| 2393 | (if (ad-compiled-p definition) | 2376 | (if (ad-compiled-p definition) |
| 2394 | (ad-real-documentation definition t) | 2377 | (documentation definition t) |
| 2395 | (car (cdr (cdr (ad-lambda-expression definition))))))) | 2378 | (car (cdr (cdr (ad-lambda-expression definition))))))) |
| 2396 | (if (or (stringp docstring) | 2379 | (if (or (stringp docstring) |
| 2397 | (natnump docstring)) | 2380 | (natnump docstring)) |
| @@ -2475,6 +2458,7 @@ For that it has to be fbound with a non-autoload definition." | |||
| 2475 | (ad-macro-p (symbol-function function))) | 2458 | (ad-macro-p (symbol-function function))) |
| 2476 | (not (ad-compiled-p (symbol-function function))))) | 2459 | (not (ad-compiled-p (symbol-function function))))) |
| 2477 | 2460 | ||
| 2461 | (defvar warning-suppress-types) ;From warnings.el. | ||
| 2478 | (defun ad-compile-function (function) | 2462 | (defun ad-compile-function (function) |
| 2479 | "Byte-compiles FUNCTION (or macro) if it is not yet compiled." | 2463 | "Byte-compiles FUNCTION (or macro) if it is not yet compiled." |
| 2480 | (interactive "aByte-compile function: ") | 2464 | (interactive "aByte-compile function: ") |
| @@ -2605,24 +2589,20 @@ The assignment starts at position INDEX." | |||
| 2605 | (let ((values-index 0) | 2589 | (let ((values-index 0) |
| 2606 | argument-access set-forms) | 2590 | argument-access set-forms) |
| 2607 | (while (setq argument-access (ad-access-argument arglist index)) | 2591 | (while (setq argument-access (ad-access-argument arglist index)) |
| 2608 | (if (symbolp argument-access) | 2592 | (push (if (symbolp argument-access) |
| 2609 | (setq set-forms | 2593 | (ad-set-argument |
| 2610 | (cons (ad-set-argument | 2594 | arglist index |
| 2611 | arglist index | 2595 | (ad-element-access values-index 'ad-vAlUeS)) |
| 2612 | (ad-element-access values-index 'ad-vAlUeS)) | 2596 | (setq arglist nil) ;; Terminate loop. |
| 2613 | set-forms)) | 2597 | (if (= (car argument-access) 0) |
| 2614 | (setq set-forms | 2598 | `(setq |
| 2615 | (cons (if (= (car argument-access) 0) | 2599 | ,(car (cdr argument-access)) |
| 2616 | (list 'setq | 2600 | ,(ad-list-access values-index 'ad-vAlUeS)) |
| 2617 | (car (cdr argument-access)) | 2601 | `(setcdr |
| 2618 | (ad-list-access values-index 'ad-vAlUeS)) | 2602 | ,(ad-list-access (1- (car argument-access)) |
| 2619 | (list 'setcdr | 2603 | (car (cdr argument-access))) |
| 2620 | (ad-list-access (1- (car argument-access)) | 2604 | ,(ad-list-access values-index 'ad-vAlUeS)))) |
| 2621 | (car (cdr argument-access))) | 2605 | set-forms) |
| 2622 | (ad-list-access values-index 'ad-vAlUeS))) | ||
| 2623 | set-forms)) | ||
| 2624 | ;; terminate loop | ||
| 2625 | (setq arglist nil)) | ||
| 2626 | (setq index (1+ index)) | 2606 | (setq index (1+ index)) |
| 2627 | (setq values-index (1+ values-index))) | 2607 | (setq values-index (1+ values-index))) |
| 2628 | (if (null set-forms) | 2608 | (if (null set-forms) |
| @@ -2631,8 +2611,8 @@ The assignment starts at position INDEX." | |||
| 2631 | (if (= (length set-forms) 1) | 2611 | (if (= (length set-forms) 1) |
| 2632 | ;; For exactly one set-form we can use values-form directly,... | 2612 | ;; For exactly one set-form we can use values-form directly,... |
| 2633 | (ad-substitute-tree | 2613 | (ad-substitute-tree |
| 2634 | (function (lambda (form) (eq form 'ad-vAlUeS))) | 2614 | (lambda (form) (eq form 'ad-vAlUeS)) |
| 2635 | (function (lambda (form) values-form)) | 2615 | (lambda (_form) values-form) |
| 2636 | (car set-forms)) | 2616 | (car set-forms)) |
| 2637 | ;; ...if we have more we have to bind it to a variable: | 2617 | ;; ...if we have more we have to bind it to a variable: |
| 2638 | `(let ((ad-vAlUeS ,values-form)) | 2618 | `(let ((ad-vAlUeS ,values-form)) |
| @@ -2702,11 +2682,10 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return | |||
| 2702 | (cond (need-apply | 2682 | (cond (need-apply |
| 2703 | ;; `apply' can take care of that directly: | 2683 | ;; `apply' can take care of that directly: |
| 2704 | (append source-reqopt-args (list source-rest-arg))) | 2684 | (append source-reqopt-args (list source-rest-arg))) |
| 2705 | (t (mapcar (function | 2685 | (t (mapcar (lambda (_arg) |
| 2706 | (lambda (arg) | 2686 | (setq target-arg-index (1+ target-arg-index)) |
| 2707 | (setq target-arg-index (1+ target-arg-index)) | 2687 | (ad-get-argument |
| 2708 | (ad-get-argument | 2688 | source-arglist target-arg-index)) |
| 2709 | source-arglist target-arg-index))) | ||
| 2710 | (append target-reqopt-args | 2689 | (append target-reqopt-args |
| 2711 | (and target-rest-arg | 2690 | (and target-rest-arg |
| 2712 | ;; If we have a rest arg gobble up | 2691 | ;; If we have a rest arg gobble up |
| @@ -2757,7 +2736,7 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return | |||
| 2757 | (let* ((origdef (ad-real-orig-definition function)) | 2736 | (let* ((origdef (ad-real-orig-definition function)) |
| 2758 | (origdoc | 2737 | (origdoc |
| 2759 | ;; Retrieve raw doc, key substitution will be taken care of later: | 2738 | ;; Retrieve raw doc, key substitution will be taken care of later: |
| 2760 | (ad-real-documentation origdef t))) | 2739 | (documentation origdef t))) |
| 2761 | (ad--make-advised-docstring origdoc function style))) | 2740 | (ad--make-advised-docstring origdoc function style))) |
| 2762 | 2741 | ||
| 2763 | (defun ad--make-advised-docstring (origdoc function &optional style) | 2742 | (defun ad--make-advised-docstring (origdoc function &optional style) |
| @@ -2771,7 +2750,7 @@ in any of these classes." | |||
| 2771 | (let* ((origdef (ad-real-orig-definition function)) | 2750 | (let* ((origdef (ad-real-orig-definition function)) |
| 2772 | (origtype (symbol-name (ad-definition-type origdef))) | 2751 | (origtype (symbol-name (ad-definition-type origdef))) |
| 2773 | (usage (help-split-fundoc origdoc function)) | 2752 | (usage (help-split-fundoc origdoc function)) |
| 2774 | paragraphs advice-docstring ad-usage) | 2753 | paragraphs advice-docstring) |
| 2775 | (setq usage (if (null usage) t (setq origdoc (cdr usage)) (car usage))) | 2754 | (setq usage (if (null usage) t (setq origdoc (cdr usage)) (car usage))) |
| 2776 | (if origdoc (setq paragraphs (list origdoc))) | 2755 | (if origdoc (setq paragraphs (list origdoc))) |
| 2777 | (unless (eq style 'plain) | 2756 | (unless (eq style 'plain) |
| @@ -2834,7 +2813,7 @@ in any of these classes." | |||
| 2834 | (orig-special-form-p (ad-special-form-p origdef)) | 2813 | (orig-special-form-p (ad-special-form-p origdef)) |
| 2835 | (orig-macro-p (ad-macro-p origdef)) | 2814 | (orig-macro-p (ad-macro-p origdef)) |
| 2836 | ;; Construct the individual pieces that we need for assembly: | 2815 | ;; Construct the individual pieces that we need for assembly: |
| 2837 | (orig-arglist (ad-arglist origdef function)) | 2816 | (orig-arglist (ad-arglist origdef)) |
| 2838 | (advised-arglist (or (ad-advised-arglist function) | 2817 | (advised-arglist (or (ad-advised-arglist function) |
| 2839 | orig-arglist)) | 2818 | orig-arglist)) |
| 2840 | (advised-interactive-form (ad-advised-interactive-form function)) | 2819 | (advised-interactive-form (ad-advised-interactive-form function)) |
| @@ -2929,8 +2908,8 @@ should be modified. The assembled function will be returned." | |||
| 2929 | (setq around-form-protected t)) | 2908 | (setq around-form-protected t)) |
| 2930 | (setq around-form | 2909 | (setq around-form |
| 2931 | (ad-substitute-tree | 2910 | (ad-substitute-tree |
| 2932 | (function (lambda (form) (eq form 'ad-do-it))) | 2911 | (lambda (form) (eq form 'ad-do-it)) |
| 2933 | (function (lambda (form) around-form)) | 2912 | (lambda (_form) around-form) |
| 2934 | (macroexp-progn (ad-body-forms (ad-advice-definition advice)))))) | 2913 | (macroexp-progn (ad-body-forms (ad-advice-definition advice)))))) |
| 2935 | 2914 | ||
| 2936 | (setq after-forms | 2915 | (setq after-forms |
| @@ -3065,10 +3044,10 @@ advised definition from scratch." | |||
| 3065 | (mapcar (function (lambda (advice) (ad-advice-name advice))) | 3044 | (mapcar (function (lambda (advice) (ad-advice-name advice))) |
| 3066 | (ad-get-enabled-advices function 'after)) | 3045 | (ad-get-enabled-advices function 'after)) |
| 3067 | (ad-definition-type original-definition) | 3046 | (ad-definition-type original-definition) |
| 3068 | (if (equal (ad-arglist original-definition function) | 3047 | (if (equal (ad-arglist original-definition) |
| 3069 | (ad-arglist cached-definition)) | 3048 | (ad-arglist cached-definition)) |
| 3070 | t | 3049 | t |
| 3071 | (ad-arglist original-definition function)) | 3050 | (ad-arglist original-definition)) |
| 3072 | (if (eq (ad-definition-type original-definition) 'function) | 3051 | (if (eq (ad-definition-type original-definition) 'function) |
| 3073 | (equal (interactive-form original-definition) | 3052 | (equal (interactive-form original-definition) |
| 3074 | (interactive-form cached-definition)))))) | 3053 | (interactive-form cached-definition)))))) |
| @@ -3113,7 +3092,7 @@ advised definition from scratch." | |||
| 3113 | (and (eq (nth 3 cache-id) (ad-definition-type original-definition)) | 3092 | (and (eq (nth 3 cache-id) (ad-definition-type original-definition)) |
| 3114 | (setq code 'arglist-mismatch) | 3093 | (setq code 'arglist-mismatch) |
| 3115 | (equal (if (eq (nth 4 cache-id) t) | 3094 | (equal (if (eq (nth 4 cache-id) t) |
| 3116 | (ad-arglist original-definition function) | 3095 | (ad-arglist original-definition) |
| 3117 | (nth 4 cache-id) ) | 3096 | (nth 4 cache-id) ) |
| 3118 | (ad-arglist cached-definition)) | 3097 | (ad-arglist cached-definition)) |
| 3119 | (setq code 'interactive-form-mismatch) | 3098 | (setq code 'interactive-form-mismatch) |
| @@ -3227,7 +3206,7 @@ advised definition from scratch." | |||
| 3227 | (ad-safe-fset 'ad-make-advised-definition-docstring | 3206 | (ad-safe-fset 'ad-make-advised-definition-docstring |
| 3228 | 'ad-make-freeze-docstring) | 3207 | 'ad-make-freeze-docstring) |
| 3229 | ;; Make sure `unique-origname' is used as the origname: | 3208 | ;; Make sure `unique-origname' is used as the origname: |
| 3230 | (ad-safe-fset 'ad-make-origname (lambda (x) unique-origname)) | 3209 | (ad-safe-fset 'ad-make-origname (lambda (_x) unique-origname)) |
| 3231 | ;; No we reset all current advice information to nil and | 3210 | ;; No we reset all current advice information to nil and |
| 3232 | ;; generate an advised definition that's solely determined | 3211 | ;; generate an advised definition that's solely determined |
| 3233 | ;; by ADVICE and the current origdef of FUNCTION: | 3212 | ;; by ADVICE and the current origdef of FUNCTION: |
| @@ -3677,28 +3656,24 @@ undone on exit of this macro." | |||
| 3677 | ;; Make forms to redefine functions to their | 3656 | ;; Make forms to redefine functions to their |
| 3678 | ;; original definitions if they are advised: | 3657 | ;; original definitions if they are advised: |
| 3679 | (setq index -1) | 3658 | (setq index -1) |
| 3680 | (mapcar | 3659 | (mapcar (lambda (function) |
| 3681 | (function | 3660 | (setq index (1+ index)) |
| 3682 | (lambda (function) | 3661 | `(ad-safe-fset |
| 3683 | (setq index (1+ index)) | 3662 | ',function |
| 3684 | `(ad-safe-fset | 3663 | (or (ad-get-orig-definition ',function) |
| 3685 | ',function | 3664 | ,(car (nth index current-bindings))))) |
| 3686 | (or (ad-get-orig-definition ',function) | 3665 | functions)) |
| 3687 | ,(car (nth index current-bindings)))))) | ||
| 3688 | functions)) | ||
| 3689 | ,@body) | 3666 | ,@body) |
| 3690 | ,@(progn | 3667 | ,@(progn |
| 3691 | ;; Make forms to back-define functions to the definitions | 3668 | ;; Make forms to back-define functions to the definitions |
| 3692 | ;; they had outside this macro call: | 3669 | ;; they had outside this macro call: |
| 3693 | (setq index -1) | 3670 | (setq index -1) |
| 3694 | (mapcar | 3671 | (mapcar (lambda (function) |
| 3695 | (function | 3672 | (setq index (1+ index)) |
| 3696 | (lambda (function) | 3673 | `(ad-safe-fset |
| 3697 | (setq index (1+ index)) | 3674 | ',function |
| 3698 | `(ad-safe-fset | 3675 | ,(car (nth index current-bindings)))) |
| 3699 | ',function | 3676 | functions)))))) |
| 3700 | ,(car (nth index current-bindings))))) | ||
| 3701 | functions)))))) | ||
| 3702 | 3677 | ||
| 3703 | 3678 | ||
| 3704 | ;; @@ Starting, stopping and recovering from the advice package magic: | 3679 | ;; @@ Starting, stopping and recovering from the advice package magic: |
| @@ -3727,7 +3702,9 @@ Use only in REAL emergencies." | |||
| 3727 | (ad-set-advice-info 'ad-activate-internal nil) | 3702 | (ad-set-advice-info 'ad-activate-internal nil) |
| 3728 | (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off) | 3703 | (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off) |
| 3729 | (ad-recover-all) | 3704 | (ad-recover-all) |
| 3730 | (setq ad-advised-functions nil)) | 3705 | (ad-do-advised-functions (function) |
| 3706 | (message "Oops! Left over advised function %S" function) | ||
| 3707 | (ad-pop-advised-function function))) | ||
| 3731 | 3708 | ||
| 3732 | (ad-start-advice) | 3709 | (ad-start-advice) |
| 3733 | 3710 | ||