summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/nadvice.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-03-10 21:22:24 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-03-10 21:22:24 -0400
commit1ea22560004f69e5e0848234aeba413141982bb4 (patch)
treedbc2f92fdb4084c4f94260e6391f7e656e9aa777 /lisp/emacs-lisp/nadvice.el
parent4538c058d073cedeff92a50211b415a2e57c3469 (diff)
downloademacs-1ea22560004f69e5e0848234aeba413141982bb4.tar.gz
* lisp/emacs-lisp/nadvice.el (advice--make-1): Fix autoloading avoidance.
(advice-add): Add a :advice--pending marker, so advice--make-1 knows when the advice is pending. (advice-remove): Remove this marker when not needed any more.
Diffstat (limited to 'lisp/emacs-lisp/nadvice.el')
-rw-r--r--lisp/emacs-lisp/nadvice.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 8dc1f19784c..f75fb23147f 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -141,11 +141,12 @@ Each element has the form (WHERE BYTECODE STACK) where:
(let ((adv-sig (gethash main advertised-signature-table))
(advice
(apply #'make-byte-code 128 byte-code
- (vector #'apply function main props) stack-depth
- nil
+ (vector #'apply function main props) stack-depth nil
(and (or (commandp function) (commandp main))
- (not (and (symbolp main) ;; Don't autoload too eagerly!
- (autoloadp (symbol-function main))))
+ ;; If we're adding the advice on advice--pending, don't
+ ;; build an interactive-form, which won't be used anyway
+ ;; and would risk autoloading `main' (or `function').
+ (not (eq main :advice--pending))
(list (advice--make-interactive-form
function main))))))
(when adv-sig (puthash advice adv-sig advertised-signature-table))
@@ -392,6 +393,8 @@ is defined as a macro, alias, command, ..."
;; - `autoload' does nothing if the function is
;; not an autoload or undefined.
((or (not nf) (autoloadp nf))
+ (unless (get symbol 'advice--pending)
+ (put symbol 'advice--pending :advice--pending))
(get symbol 'advice--pending))
(t (symbol-function symbol)))
function props)
@@ -416,6 +419,8 @@ of the piece of advice."
function)
(unless (advice--p (advice--symbol-function symbol))
;; Not advised any more.
+ (when (eq (get symbol 'advice--pending) :advice--pending)
+ (put symbol 'advice--pending nil))
(remove-function (get symbol 'defalias-fset-function)
#'advice--defalias-fset)
(let ((asr (get symbol 'advice--saved-rewrite)))