summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/advice.el
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2011-05-23 11:38:28 -0300
committerStefan Monnier <monnier@iro.umontreal.ca>2011-05-23 11:38:28 -0300
commit7de88b6e91083d81c92bc70f311d94db8ae0f7e7 (patch)
tree52468ad4724cf9b18a5049a95dab6326fe06cb7d /lisp/emacs-lisp/advice.el
parentbbca48fe464edeb313f14c99fe8c10b8a98017c4 (diff)
downloademacs-7de88b6e91083d81c92bc70f311d94db8ae0f7e7.tar.gz
* lisp/emacs-lisp/advice.el (ad-read-advised-function):
Use `function-called-at-point' as the default default, if it has advice and passes PREDICATE.
Diffstat (limited to 'lisp/emacs-lisp/advice.el')
-rw-r--r--lisp/emacs-lisp/advice.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 5934975e36a..a245a91c5c1 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -2135,16 +2135,27 @@ Redefining advices affect the construction of an advised definition."
;; @@ Interactive input functions:
;; ===============================
+(declare-function 'function-called-at-point "help")
+
(defun ad-read-advised-function (&optional prompt predicate default)
"Read name of advised function with completion from the minibuffer.
An optional PROMPT will be used to prompt for the function. PREDICATE
plays the same role as for `try-completion' (which see). DEFAULT will
-be returned on empty input (defaults to the first advised function for
-which PREDICATE returns non-nil)."
+be returned on empty input (defaults to the first advised function or
+function at point for which PREDICATE returns non-nil)."
(if (null ad-advised-functions)
(error "ad-read-advised-function: There are no advised functions"))
(setq default
(or default
+ ;; Prefer func name at point, if it's in ad-advised-functions etc.
+ (let ((function (progn
+ (require 'help)
+ (function-called-at-point))))
+ (and function
+ (assoc (symbol-name function) ad-advised-functions)
+ (or (null predicate)
+ (funcall predicate function))
+ function))
(ad-do-advised-functions (function)
(if (or (null predicate)
(funcall predicate function))