--- advice.el.~1.68.~ 2009-10-08 11:00:28.000000000 +1100 +++ advice.el 2011-03-21 10:37:14.000000000 +1100 @@ -2200,16 +2200,29 @@ ;; @@ 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)." +plays the same role as for `try-completion' (which see). + +DEFAULT is returned on empty input. DEFAULT defaults to the +function name at point if it's advised and passes PREDICATE, +otherwise to the first advised function which passes PREDICATE." (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))