1 |
;;; advice.el --- an overloading mechanism for Emacs Lisp functions |
;;; advice.el --- an overloading mechanism for Emacs Lisp functions |
2 |
|
|
3 |
;; Copyright (C) 1993,1994,2000,01,2004 Free Software Foundation, Inc. |
;; Copyright (C) 1993,1994,2000,01,2004,2005 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Hans Chalupsky <hans@cs.buffalo.edu> |
;; Author: Hans Chalupsky <hans@cs.buffalo.edu> |
6 |
;; Maintainer: FSF |
;; Maintainer: FSF |
2173 |
;; ============================================ |
;; ============================================ |
2174 |
;; The advice-info of an advised function contains its `origname' which is |
;; The advice-info of an advised function contains its `origname' which is |
2175 |
;; a symbol that is fbound to the original definition available at the first |
;; a symbol that is fbound to the original definition available at the first |
2176 |
;; proper activation of the function after a legal re/definition. If the |
;; proper activation of the function after a valid re/definition. If the |
2177 |
;; original was defined via fcell indirection then `origname' will be defined |
;; original was defined via fcell indirection then `origname' will be defined |
2178 |
;; just so. Hence, to get hold of the actual original definition of a function |
;; just so. Hence, to get hold of the actual original definition of a function |
2179 |
;; we need to use `ad-real-orig-definition'. |
;; we need to use `ad-real-orig-definition'. |
2238 |
ad-advice-classes)) |
ad-advice-classes)) |
2239 |
|
|
2240 |
(defun ad-read-advice-class (function &optional prompt default) |
(defun ad-read-advice-class (function &optional prompt default) |
2241 |
"Read a legal advice class with completion from the minibuffer. |
"Read a valid advice class with completion from the minibuffer. |
2242 |
An optional PROMPT will be used to prompt for the class. DEFAULT will |
An optional PROMPT will be used to prompt for the class. DEFAULT will |
2243 |
be returned on empty input (defaults to the first non-empty advice |
be returned on empty input (defaults to the first non-empty advice |
2244 |
class of FUNCTION)." |
class of FUNCTION)." |
2312 |
(defun ad-find-some-advice (function class name) |
(defun ad-find-some-advice (function class name) |
2313 |
"Find the first of FUNCTION's advices in CLASS matching NAME. |
"Find the first of FUNCTION's advices in CLASS matching NAME. |
2314 |
NAME can be a symbol or a regular expression matching part of an advice name. |
NAME can be a symbol or a regular expression matching part of an advice name. |
2315 |
If CLASS is `any' all legal advice classes will be checked." |
If CLASS is `any' all valid advice classes will be checked." |
2316 |
(if (ad-is-advised function) |
(if (ad-is-advised function) |
2317 |
(let (found-advice) |
(let (found-advice) |
2318 |
(ad-dolist (advice-class ad-advice-classes) |
(ad-dolist (advice-class ad-advice-classes) |
2332 |
"Set enable FLAG of FUNCTION's advices in CLASS matching NAME. |
"Set enable FLAG of FUNCTION's advices in CLASS matching NAME. |
2333 |
If NAME is a string rather than a symbol then it's interpreted as a regular |
If NAME is a string rather than a symbol then it's interpreted as a regular |
2334 |
expression and all advices whose name contain a match for it will be |
expression and all advices whose name contain a match for it will be |
2335 |
affected. If CLASS is `any' advices in all legal advice classes will be |
affected. If CLASS is `any' advices in all valid advice classes will be |
2336 |
considered. The number of changed advices will be returned (or nil if |
considered. The number of changed advices will be returned (or nil if |
2337 |
FUNCTION was not advised)." |
FUNCTION was not advised)." |
2338 |
(if (ad-is-advised function) |
(if (ad-is-advised function) |
2369 |
|
|
2370 |
(defun ad-enable-regexp-internal (regexp class flag) |
(defun ad-enable-regexp-internal (regexp class flag) |
2371 |
"Set enable FLAGs of all CLASS advices whose name contains a REGEXP match. |
"Set enable FLAGs of all CLASS advices whose name contains a REGEXP match. |
2372 |
If CLASS is `any' all legal advice classes are considered. The number of |
If CLASS is `any' all valid advice classes are considered. The number of |
2373 |
affected advices will be returned." |
affected advices will be returned." |
2374 |
(let ((matched-advices 0)) |
(let ((matched-advices 0)) |
2375 |
(ad-do-advised-functions (advised-function) |
(ad-do-advised-functions (advised-function) |
3755 |
(error nil)))) |
(error nil)))) |
3756 |
|
|
3757 |
|
|
3758 |
;; Completion alist of legal `defadvice' flags |
;; Completion alist of valid `defadvice' flags |
3759 |
(defvar ad-defadvice-flags |
(defvar ad-defadvice-flags |
3760 |
'(("protect") ("disable") ("activate") |
'(("protect") ("disable") ("activate") |
3761 |
("compile") ("preactivate") ("freeze"))) |
("compile") ("preactivate") ("freeze"))) |