summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/advice.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/advice.el')
-rw-r--r--lisp/emacs-lisp/advice.el42
1 files changed, 9 insertions, 33 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 8239522c0f8..16c12aad29b 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -1776,27 +1776,6 @@ generates a copy of TREE."
(funcall fUnCtIoN tReE))
(t tReE)))
-;; @@ Save real definitions of subrs used by Advice:
-;; =================================================
-;; Advice depends on the real, unmodified functionality of various subrs,
-;; we save them here so advised versions will not interfere (eventually,
-;; we will save all subrs used in code generated by Advice):
-
-(defmacro ad-save-real-definition (function)
- (let ((saved-function (intern (format "ad-real-%s" function))))
- ;; Make sure the compiler is loaded during macro expansion:
- (require 'byte-compile "bytecomp")
- `(if (not (fboundp ',saved-function))
- (progn (fset ',saved-function (symbol-function ',function))
- ;; Copy byte-compiler properties:
- ,@(if (get function 'byte-compile)
- `((put ',saved-function 'byte-compile
- ',(get function 'byte-compile))))
- ,@(if (get function 'byte-opcode)
- `((put ',saved-function 'byte-opcode
- ',(get function 'byte-opcode))))))))
-
-
;; @@ Advice info access fns:
;; ==========================
@@ -1849,9 +1828,12 @@ On each iteration VAR will be bound to the name of an advised function
(defsubst ad-set-advice-info (function advice-info)
(cond
- (advice-info (put function 'defalias-fset-function #'ad--defalias-fset))
+ (advice-info
+ (add-function :around (get function 'defalias-fset-function)
+ #'ad--defalias-fset))
((get function 'defalias-fset-function)
- (put function 'defalias-fset-function nil)))
+ (remove-function (get function 'defalias-fset-function)
+ #'ad--defalias-fset)))
(put function 'ad-advice-info advice-info))
(defmacro ad-copy-advice-info (function)
@@ -1974,8 +1956,8 @@ Redefining advices affect the construction of an advised definition."
;; to `ad-activate' by using `ad-with-auto-activation-disabled' where
;; appropriate, especially in a safe version of `fset'.
-(defun ad--defalias-fset (function definition)
- (fset function definition)
+(defun ad--defalias-fset (fsetfun function definition)
+ (funcall (or fsetfun #'fset) function definition)
(ad-activate-internal function nil))
;; For now define `ad-activate-internal' to the dummy definition:
@@ -2310,12 +2292,6 @@ See Info node `(elisp)Computed Advice' for detailed documentation."
"Take a macro function DEFINITION and make a lambda out of it."
`(cdr ,definition))
-(defun ad-special-form-p (definition)
- "Non-nil if and only if DEFINITION is a special form."
- (if (and (symbolp definition) (fboundp definition))
- (setq definition (indirect-function definition)))
- (and (subrp definition) (eq (cdr (subr-arity definition)) 'unevalled)))
-
(defmacro ad-subr-p (definition)
;;"non-nil if DEFINITION is a subr."
(list 'subrp definition))
@@ -2415,7 +2391,7 @@ definition (see the code for `documentation')."
(cond
((ad-macro-p definition) 'macro)
((ad-subr-p definition)
- (if (ad-special-form-p definition)
+ (if (special-form-p definition)
'special-form
'subr))
((or (ad-lambda-p definition)
@@ -2804,7 +2780,7 @@ in any of these classes."
(origname (ad-get-advice-info-field function 'origname))
(orig-interactive-p (commandp origdef))
(orig-subr-p (ad-subr-p origdef))
- (orig-special-form-p (ad-special-form-p origdef))
+ (orig-special-form-p (special-form-p origdef))
(orig-macro-p (ad-macro-p origdef))
;; Construct the individual pieces that we need for assembly:
(orig-arglist (ad-arglist origdef))