emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104327: * lisp/emacs-lisp/advice.el


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104327: * lisp/emacs-lisp/advice.el (ad-read-advised-function):
Date: Mon, 23 May 2011 11:38:28 -0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104327
author: Kevin Ryde <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2011-05-23 11:38:28 -0300
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/advice.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-23 01:15:17 +0000
+++ b/lisp/ChangeLog    2011-05-23 14:38:28 +0000
@@ -1,3 +1,9 @@
+2011-05-23  Kevin Ryde  <address@hidden>
+
+       * 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  <address@hidden>
 
        * emacs-lisp/bytecomp.el (byte-compile-function-form): Only call

=== modified file 'lisp/emacs-lisp/advice.el'
--- a/lisp/emacs-lisp/advice.el 2011-04-13 17:56:47 +0000
+++ b/lisp/emacs-lisp/advice.el 2011-05-23 14:38:28 +0000
@@ -2135,16 +2135,27 @@
 ;; @@ 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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]