diff options
| author | Kevin Ryde | 2011-05-23 11:38:28 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-05-23 11:38:28 -0300 |
| commit | 7de88b6e91083d81c92bc70f311d94db8ae0f7e7 (patch) | |
| tree | 52468ad4724cf9b18a5049a95dab6326fe06cb7d | |
| parent | bbca48fe464edeb313f14c99fe8c10b8a98017c4 (diff) | |
| download | emacs-7de88b6e91083d81c92bc70f311d94db8ae0f7e7.tar.gz emacs-7de88b6e91083d81c92bc70f311d94db8ae0f7e7.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2011-05-23 Kevin Ryde <user42@zip.com.au> | ||
| 2 | |||
| 3 | * emacs-lisp/advice.el (ad-read-advised-function): | ||
| 4 | Use `function-called-at-point' as the default default, if it has | ||
| 5 | advice and passes PREDICATE. | ||
| 6 | |||
| 1 | 2011-05-23 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2011-05-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-function-form): Only call | 9 | * 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." | |||
| 2135 | ;; @@ Interactive input functions: | 2135 | ;; @@ Interactive input functions: |
| 2136 | ;; =============================== | 2136 | ;; =============================== |
| 2137 | 2137 | ||
| 2138 | (declare-function 'function-called-at-point "help") | ||
| 2139 | |||
| 2138 | (defun ad-read-advised-function (&optional prompt predicate default) | 2140 | (defun ad-read-advised-function (&optional prompt predicate default) |
| 2139 | "Read name of advised function with completion from the minibuffer. | 2141 | "Read name of advised function with completion from the minibuffer. |
| 2140 | An optional PROMPT will be used to prompt for the function. PREDICATE | 2142 | An optional PROMPT will be used to prompt for the function. PREDICATE |
| 2141 | plays the same role as for `try-completion' (which see). DEFAULT will | 2143 | plays the same role as for `try-completion' (which see). DEFAULT will |
| 2142 | be returned on empty input (defaults to the first advised function for | 2144 | be returned on empty input (defaults to the first advised function or |
| 2143 | which PREDICATE returns non-nil)." | 2145 | function at point for which PREDICATE returns non-nil)." |
| 2144 | (if (null ad-advised-functions) | 2146 | (if (null ad-advised-functions) |
| 2145 | (error "ad-read-advised-function: There are no advised functions")) | 2147 | (error "ad-read-advised-function: There are no advised functions")) |
| 2146 | (setq default | 2148 | (setq default |
| 2147 | (or default | 2149 | (or default |
| 2150 | ;; Prefer func name at point, if it's in ad-advised-functions etc. | ||
| 2151 | (let ((function (progn | ||
| 2152 | (require 'help) | ||
| 2153 | (function-called-at-point)))) | ||
| 2154 | (and function | ||
| 2155 | (assoc (symbol-name function) ad-advised-functions) | ||
| 2156 | (or (null predicate) | ||
| 2157 | (funcall predicate function)) | ||
| 2158 | function)) | ||
| 2148 | (ad-do-advised-functions (function) | 2159 | (ad-do-advised-functions (function) |
| 2149 | (if (or (null predicate) | 2160 | (if (or (null predicate) |
| 2150 | (funcall predicate function)) | 2161 | (funcall predicate function)) |