aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-11-12 23:05:35 -0500
committerStefan Monnier2012-11-12 23:05:35 -0500
commit7db1bda8a4a757581f2b93a90657ae667d7e62fb (patch)
tree015175b922eb6c54426c4ed2ec458ca2f05e9b46
parent4f0552c2eaae1ea6648bdc4c172f642a1354a9c0 (diff)
downloademacs-7db1bda8a4a757581f2b93a90657ae667d7e62fb.tar.gz
emacs-7db1bda8a4a757581f2b93a90657ae667d7e62fb.zip
* lisp/emacs-lisp/advice.el: Remove support for freezing.
(ad-make-freeze-docstring, ad-make-freeze-definition): Remove functions. (ad-make-single-advice-docstring, ad-defadvice-flags, defadvice): Remove support for `freeze'.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/emacs-lisp/advice.el138
3 files changed, 30 insertions, 119 deletions
diff --git a/etc/NEWS b/etc/NEWS
index b6d90b7f8c1..fbe24c8345f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -43,6 +43,8 @@ It is layered as:
43 43
44* Incompatible Lisp Changes in Emacs 24.4 44* Incompatible Lisp Changes in Emacs 24.4
45 45
46** `defadvice' does not honor the `freeze' flag any more.
47
46** `dolist' in lexical-binding mode does not bind VAR in RESULT any more. 48** `dolist' in lexical-binding mode does not bind VAR in RESULT any more.
47VAR was bound to nil which was not tremendously useful and just lead to 49VAR was bound to nil which was not tremendously useful and just lead to
48spurious warnings about an unused var. 50spurious warnings about an unused var.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d04c42da4f1..bab44db48a1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12012-11-13 Stefan Monnier <monnier@iro.umontreal.ca> 12012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/advice.el: Remove support for freezing.
4 (ad-make-freeze-docstring, ad-make-freeze-definition): Remove functions.
5 (ad-make-single-advice-docstring, ad-defadvice-flags, defadvice):
6 Remove support for `freeze'.
7
3 * emacs-lisp/cl.el (dolist, dotimes, declare): Use advice-add to 8 * emacs-lisp/cl.el (dolist, dotimes, declare): Use advice-add to
4 override the default. 9 override the default.
5 * emacs-lisp/cl-macs.el (cl-dolist, cl-dotimes): Rewrite without using 10 * emacs-lisp/cl-macs.el (cl-dolist, cl-dotimes): Rewrite without using
@@ -16,8 +21,8 @@
16 21
172012-11-13 Dmitry Gutov <dgutov@yandex.ru> 222012-11-13 Dmitry Gutov <dgutov@yandex.ru>
18 23
19 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Never 24 * progmodes/ruby-mode.el (ruby-font-lock-keywords):
20 font-lock the beginning of singleton class as heredoc. 25 Never font-lock the beginning of singleton class as heredoc.
21 26
222012-11-13 Stefan Monnier <monnier@iro.umontreal.ca> 272012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
23 28
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 16c12aad29b..ecaf6861a6c 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -2686,11 +2686,6 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return
2686 (let ((advice-docstring (ad-docstring (ad-advice-definition advice)))) 2686 (let ((advice-docstring (ad-docstring (ad-advice-definition advice))))
2687 (cond ((eq style 'plain) 2687 (cond ((eq style 'plain)
2688 advice-docstring) 2688 advice-docstring)
2689 ((eq style 'freeze)
2690 (format "Permanent %s-advice `%s':%s%s"
2691 class (ad-advice-name advice)
2692 (if advice-docstring "\n" "")
2693 (or advice-docstring "")))
2694 (t (if advice-docstring 2689 (t (if advice-docstring
2695 (format "%s-advice `%s':\n%s" 2690 (format "%s-advice `%s':\n%s"
2696 (capitalize (symbol-name class)) 2691 (capitalize (symbol-name class))
@@ -2713,7 +2708,7 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return
2713 "Construct a documentation string for the advised FUNCTION. 2708 "Construct a documentation string for the advised FUNCTION.
2714It concatenates the original documentation with the documentation 2709It concatenates the original documentation with the documentation
2715strings of the individual pieces of advice which will be formatted 2710strings of the individual pieces of advice which will be formatted
2716according to STYLE. STYLE can be `plain' or `freeze', everything else 2711according to STYLE. STYLE can be `plain', everything else
2717will be interpreted as `default'. The order of the advice documentation 2712will be interpreted as `default'. The order of the advice documentation
2718strings corresponds to before/around/after and the individual ordering 2713strings corresponds to before/around/after and the individual ordering
2719in any of these classes." 2714in any of these classes."
@@ -2742,8 +2737,6 @@ in any of these classes."
2742 2737
2743(defun ad-make-plain-docstring (function) 2738(defun ad-make-plain-docstring (function)
2744 (ad-make-advised-docstring function 'plain)) 2739 (ad-make-advised-docstring function 'plain))
2745(defun ad-make-freeze-docstring (function)
2746 (ad-make-advised-docstring function 'freeze))
2747 2740
2748;; @@@ Accessing overriding arglists and interactive forms: 2741;; @@@ Accessing overriding arglists and interactive forms:
2749;; ======================================================== 2742;; ========================================================
@@ -3125,83 +3118,6 @@ advised definition from scratch."
3125 (fmakunbound function))))) 3118 (fmakunbound function)))))
3126 3119
3127 3120
3128;; @@ Freezing:
3129;; ============
3130;; Freezing transforms a `defadvice' into a redefining `defun/defmacro'
3131;; for the advised function without keeping any advice information. This
3132;; feature was jwz's idea: It generates a dumpable function definition
3133;; whose documentation can be written to the DOC file, and the generated
3134;; code does not need any Advice runtime support. Of course, frozen advices
3135;; cannot be undone.
3136
3137;; Freezing only considers the advice of the particular `defadvice', other
3138;; already existing advices for the same function will be ignored. To ensure
3139;; proper interaction when an already advised function gets redefined with
3140;; a frozen advice, frozen advices always use the actual original definition
3141;; of the function, i.e., they are always at the core of the onion. E.g., if
3142;; an already advised function gets redefined with a frozen advice and then
3143;; unadvised, the frozen advice remains as the new definition of the function.
3144
3145;; While multiple freeze advices for a single function or freeze-advising
3146;; of an already advised function are possible, they are better avoided,
3147;; because definition/compile/load ordering is relevant, and it becomes
3148;; incomprehensible pretty quickly.
3149
3150(defun ad-make-freeze-definition (function advice class position)
3151 (if (not (ad-has-proper-definition function))
3152 (error
3153 "ad-make-freeze-definition: `%s' is not yet defined"
3154 function))
3155 (cl-letf*
3156 ((name (ad-advice-name advice))
3157 ;; With a unique origname we can have multiple freeze advices
3158 ;; for the same function, each overloading the previous one:
3159 (unique-origname
3160 (intern (format "%s-%s-%s" (ad-make-origname function) class name)))
3161 (orig-definition
3162 ;; If FUNCTION is already advised, we'll use its current origdef
3163 ;; as the original definition of the frozen advice:
3164 (or (ad-get-orig-definition function)
3165 (symbol-function function)))
3166 (old-advice-info
3167 (if (ad-is-advised function)
3168 (ad-copy-advice-info function)))
3169 ;; Make sure we construct a proper docstring:
3170 ((symbol-function 'ad-make-advised-definition-docstring)
3171 #'ad-make-freeze-docstring)
3172 ;; Make sure `unique-origname' is used as the origname:
3173 ((symbol-function 'ad-make-origname) (lambda (_x) unique-origname))
3174 (frozen-definition
3175 (unwind-protect
3176 (progn
3177 ;; No we reset all current advice information to nil and
3178 ;; generate an advised definition that's solely determined
3179 ;; by ADVICE and the current origdef of FUNCTION:
3180 (ad-set-advice-info function nil)
3181 (ad-add-advice function advice class position)
3182 ;; The following will provide proper real docstrings as
3183 ;; well as a definition that will make the compiler happy:
3184 (ad-set-orig-definition function orig-definition)
3185 (ad-make-advised-definition function))
3186 ;; Restore the old advice state:
3187 (ad-set-advice-info function old-advice-info))))
3188 (if frozen-definition
3189 (let* ((macro-p (ad-macro-p frozen-definition))
3190 (body (cdr (if macro-p
3191 (ad-lambdafy frozen-definition)
3192 frozen-definition))))
3193 `(progn
3194 (if (not (fboundp ',unique-origname))
3195 (fset ',unique-origname
3196 ;; avoid infinite recursion in case the function
3197 ;; we want to freeze is already advised:
3198 (or (ad-get-orig-definition ',function)
3199 (symbol-function ',function))))
3200 (,(if macro-p 'defmacro 'defun)
3201 ,function
3202 ,@body))))))
3203
3204
3205;; @@ Activation and definition handling: 3121;; @@ Activation and definition handling:
3206;; ====================================== 3122;; ======================================
3207 3123
@@ -3468,7 +3384,7 @@ deactivation, which might run hooks and get into other trouble."
3468;; Completion alist of valid `defadvice' flags 3384;; Completion alist of valid `defadvice' flags
3469(defvar ad-defadvice-flags 3385(defvar ad-defadvice-flags
3470 '(("protect") ("disable") ("activate") 3386 '(("protect") ("disable") ("activate")
3471 ("compile") ("preactivate") ("freeze"))) 3387 ("compile") ("preactivate")))
3472 3388
3473;;;###autoload 3389;;;###autoload
3474(defmacro defadvice (function args &rest body) 3390(defmacro defadvice (function args &rest body)
@@ -3487,7 +3403,7 @@ POSITION ::= `first' | `last' | NUMBER. Optional, defaults to `first',
3487ARGLIST ::= An optional argument list to be used for the advised function 3403ARGLIST ::= An optional argument list to be used for the advised function
3488 instead of the argument list of the original. The first one found in 3404 instead of the argument list of the original. The first one found in
3489 before/around/after-advices will be used. 3405 before/around/after-advices will be used.
3490FLAG ::= `protect'|`disable'|`activate'|`compile'|`preactivate'|`freeze'. 3406FLAG ::= `protect'|`disable'|`activate'|`compile'|`preactivate'.
3491 All flags can be specified with unambiguous initial substrings. 3407 All flags can be specified with unambiguous initial substrings.
3492DOCSTRING ::= Optional documentation for this piece of advice. 3408DOCSTRING ::= Optional documentation for this piece of advice.
3493INTERACTIVE-FORM ::= Optional interactive form to be used for the advised 3409INTERACTIVE-FORM ::= Optional interactive form to be used for the advised
@@ -3513,13 +3429,6 @@ time. This generates a compiled advised definition according to the current
3513advice state that will be used during activation if appropriate. Only use 3429advice state that will be used during activation if appropriate. Only use
3514this if the `defadvice' gets actually compiled. 3430this if the `defadvice' gets actually compiled.
3515 3431
3516`freeze': Expands the `defadvice' into a redefining `defun/defmacro' according
3517to this particular single advice. No other advice information will be saved.
3518Frozen advices cannot be undone, they behave like a hard redefinition of
3519the advised function. `freeze' implies `activate' and `preactivate'. The
3520documentation of the advised function can be dumped onto the `DOC' file
3521during preloading.
3522
3523See Info node `(elisp)Advising Functions' for comprehensive documentation. 3432See Info node `(elisp)Advising Functions' for comprehensive documentation.
3524usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...) 3433usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
3525 [DOCSTRING] [INTERACTIVE-FORM] 3434 [DOCSTRING] [INTERACTIVE-FORM]
@@ -3569,29 +3478,24 @@ usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
3569 (ad-preactivate-advice 3478 (ad-preactivate-advice
3570 function advice class position)))) 3479 function advice class position))))
3571 ;; Now for the things to be done at evaluation time: 3480 ;; Now for the things to be done at evaluation time:
3572 (if (memq 'freeze flags) 3481 `(progn
3573 ;; jwz's idea: Freeze the advised definition into a dumpable 3482 (ad-add-advice ',function ',advice ',class ',position)
3574 ;; defun/defmacro whose docs can be written to the DOC file: 3483 ,@(if preactivation
3575 (ad-make-freeze-definition function advice class position) 3484 `((ad-set-cache
3576 ;; the normal case: 3485 ',function
3577 `(progn 3486 ;; the function will get compiled:
3578 (ad-add-advice ',function ',advice ',class ',position) 3487 ,(cond ((ad-macro-p (car preactivation))
3579 ,@(if preactivation 3488 `(ad-macrofy
3580 `((ad-set-cache 3489 (function
3581 ',function 3490 ,(ad-lambdafy
3582 ;; the function will get compiled: 3491 (car preactivation)))))
3583 ,(cond ((ad-macro-p (car preactivation)) 3492 (t `(function
3584 `(ad-macrofy 3493 ,(car preactivation))))
3585 (function 3494 ',(car (cdr preactivation)))))
3586 ,(ad-lambdafy 3495 ,@(if (memq 'activate flags)
3587 (car preactivation))))) 3496 `((ad-activate ',function
3588 (t `(function 3497 ,(if (memq 'compile flags) t))))
3589 ,(car preactivation)))) 3498 ',function)))
3590 ',(car (cdr preactivation)))))
3591 ,@(if (memq 'activate flags)
3592 `((ad-activate ',function
3593 ,(if (memq 'compile flags) t))))
3594 ',function))))
3595 3499
3596 3500
3597;; @@ Tools: 3501;; @@ Tools: