From 7de88b6e91083d81c92bc70f311d94db8ae0f7e7 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Mon, 23 May 2011 11:38:28 -0300 Subject: [PATCH] * 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. --- lisp/ChangeLog | 6 ++++++ lisp/emacs-lisp/advice.el | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f246b8a8951..95cae40aebe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-05-23 Kevin Ryde + + * emacs-lisp/advice.el (ad-read-advised-function): + Use `function-called-at-point' as the default default, if it has + advice and passes PREDICATE. + 2011-05-23 Stefan Monnier * emacs-lisp/bytecomp.el (byte-compile-function-form): Only call 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)) -- 2.39.2