diff options
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/nadvice.el | 13 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 81f70435627..7998b7aa8fb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-03-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/nadvice.el (advice--make-1): Fix autoloading avoidance. | ||
| 4 | (advice-add): Add a :advice--pending marker, so advice--make-1 knows | ||
| 5 | when the advice is pending. | ||
| 6 | (advice-remove): Remove this marker when not needed any more. | ||
| 7 | |||
| 1 | 2014-03-11 Juanma Barranquero <lekktu@gmail.com> | 8 | 2014-03-11 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 9 | ||
| 3 | * frameset.el: Separate options for reusing frames and cleaning up. | 10 | * frameset.el: Separate options for reusing frames and cleaning up. |
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: | |||
| 141 | (let ((adv-sig (gethash main advertised-signature-table)) | 141 | (let ((adv-sig (gethash main advertised-signature-table)) |
| 142 | (advice | 142 | (advice |
| 143 | (apply #'make-byte-code 128 byte-code | 143 | (apply #'make-byte-code 128 byte-code |
| 144 | (vector #'apply function main props) stack-depth | 144 | (vector #'apply function main props) stack-depth nil |
| 145 | nil | ||
| 146 | (and (or (commandp function) (commandp main)) | 145 | (and (or (commandp function) (commandp main)) |
| 147 | (not (and (symbolp main) ;; Don't autoload too eagerly! | 146 | ;; If we're adding the advice on advice--pending, don't |
| 148 | (autoloadp (symbol-function main)))) | 147 | ;; build an interactive-form, which won't be used anyway |
| 148 | ;; and would risk autoloading `main' (or `function'). | ||
| 149 | (not (eq main :advice--pending)) | ||
| 149 | (list (advice--make-interactive-form | 150 | (list (advice--make-interactive-form |
| 150 | function main)))))) | 151 | function main)))))) |
| 151 | (when adv-sig (puthash advice adv-sig advertised-signature-table)) | 152 | (when adv-sig (puthash advice adv-sig advertised-signature-table)) |
| @@ -392,6 +393,8 @@ is defined as a macro, alias, command, ..." | |||
| 392 | ;; - `autoload' does nothing if the function is | 393 | ;; - `autoload' does nothing if the function is |
| 393 | ;; not an autoload or undefined. | 394 | ;; not an autoload or undefined. |
| 394 | ((or (not nf) (autoloadp nf)) | 395 | ((or (not nf) (autoloadp nf)) |
| 396 | (unless (get symbol 'advice--pending) | ||
| 397 | (put symbol 'advice--pending :advice--pending)) | ||
| 395 | (get symbol 'advice--pending)) | 398 | (get symbol 'advice--pending)) |
| 396 | (t (symbol-function symbol))) | 399 | (t (symbol-function symbol))) |
| 397 | function props) | 400 | function props) |
| @@ -416,6 +419,8 @@ of the piece of advice." | |||
| 416 | function) | 419 | function) |
| 417 | (unless (advice--p (advice--symbol-function symbol)) | 420 | (unless (advice--p (advice--symbol-function symbol)) |
| 418 | ;; Not advised any more. | 421 | ;; Not advised any more. |
| 422 | (when (eq (get symbol 'advice--pending) :advice--pending) | ||
| 423 | (put symbol 'advice--pending nil)) | ||
| 419 | (remove-function (get symbol 'defalias-fset-function) | 424 | (remove-function (get symbol 'defalias-fset-function) |
| 420 | #'advice--defalias-fset) | 425 | #'advice--defalias-fset) |
| 421 | (let ((asr (get symbol 'advice--saved-rewrite))) | 426 | (let ((asr (get symbol 'advice--saved-rewrite))) |