diff options
| author | Glenn Morris | 2008-11-15 23:36:26 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-11-15 23:36:26 +0000 |
| commit | f5e7fdddfb84f0040257d4f3e67e29ccd4d6da18 (patch) | |
| tree | e97b23e450eeb49cc807d25043bf093c910bca77 | |
| parent | 43ae2c48f7e87b8ed6143781507cc7063af1c941 (diff) | |
| download | emacs-f5e7fdddfb84f0040257d4f3e67e29ccd4d6da18.tar.gz emacs-f5e7fdddfb84f0040257d4f3e67e29ccd4d6da18.zip | |
(find-function-advised-original): New.
(find-function-C-source, find-function-noselect):
Use find-function-advised-original to handle advised funcs. (Bug#789)
(find-function-noselect): Add missing "is" in alias message.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/emacs-lisp/find-func.el | 28 |
2 files changed, 32 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 506e8ebd2cc..923802156e7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,4 +1,14 @@ | |||
| 1 | 2008-11-15 Glenn Morris <rgm@gnu.org> | 1 | 2008-11-15 Glenn Morris <rgm@gnu.org> |
| 2 | Martin Rudalics <rudalics@gmx.at> | ||
| 3 | |||
| 4 | * emacs-lisp/find-func.el (find-function-advised-original): New. | ||
| 5 | (find-function-C-source, find-function-noselect): | ||
| 6 | Use find-function-advised-original to handle advised funcs. (Bug#789) | ||
| 7 | |||
| 8 | 2008-11-15 Glenn Morris <rgm@gnu.org> | ||
| 9 | |||
| 10 | * emacs-lisp/find-func.el (find-function-noselect): Add missing "is" in | ||
| 11 | alias message. | ||
| 2 | 12 | ||
| 3 | * uniquify.el (uniquify-maybe-rerationalize-w/o-cb): | 13 | * uniquify.el (uniquify-maybe-rerationalize-w/o-cb): |
| 4 | Remove uniquify-after-kill-buffer-p dependency. | 14 | Remove uniquify-after-kill-buffer-p dependency. |
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 015e75723dd..7ffc58099fb 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el | |||
| @@ -165,6 +165,17 @@ See the functions `find-function' and `find-variable'." | |||
| 165 | If nil, do not try to find the source code of functions and variables | 165 | If nil, do not try to find the source code of functions and variables |
| 166 | defined in C.") | 166 | defined in C.") |
| 167 | 167 | ||
| 168 | (declare-function ad-get-advice-info "advice" (function)) | ||
| 169 | |||
| 170 | (defun find-function-advised-original (func) | ||
| 171 | "Return the original function symbol of an advised function FUNC. | ||
| 172 | If FUNC is not the symbol of an advised function, just returns FUNC." | ||
| 173 | (or (and (symbolp func) | ||
| 174 | (featurep 'advice) | ||
| 175 | (let ((ofunc (cdr (assq 'origname (ad-get-advice-info func))))) | ||
| 176 | (and (fboundp ofunc) ofunc))) | ||
| 177 | func)) | ||
| 178 | |||
| 168 | (defun find-function-C-source (fun-or-var file type) | 179 | (defun find-function-C-source (fun-or-var file type) |
| 169 | "Find the source location where FUN-OR-VAR is defined in FILE. | 180 | "Find the source location where FUN-OR-VAR is defined in FILE. |
| 170 | TYPE should be nil to find a function, or `defvar' to find a variable." | 181 | TYPE should be nil to find a function, or `defvar' to find a variable." |
| @@ -176,7 +187,10 @@ TYPE should be nil to find a function, or `defvar' to find a variable." | |||
| 176 | (error "The C source file %s is not available" | 187 | (error "The C source file %s is not available" |
| 177 | (file-name-nondirectory file))) | 188 | (file-name-nondirectory file))) |
| 178 | (unless type | 189 | (unless type |
| 179 | (setq fun-or-var (indirect-function fun-or-var))) | 190 | ;; Either or both an alias and its target might be advised. |
| 191 | (setq fun-or-var (find-function-advised-original | ||
| 192 | (indirect-function | ||
| 193 | (find-function-advised-original fun-or-var))))) | ||
| 180 | (with-current-buffer (find-file-noselect file) | 194 | (with-current-buffer (find-file-noselect file) |
| 181 | (goto-char (point-min)) | 195 | (goto-char (point-min)) |
| 182 | (unless (re-search-forward | 196 | (unless (re-search-forward |
| @@ -292,19 +306,21 @@ If the file where FUNCTION is defined is not known, then it is | |||
| 292 | searched for in `find-function-source-path' if non-nil, otherwise | 306 | searched for in `find-function-source-path' if non-nil, otherwise |
| 293 | in `load-path'." | 307 | in `load-path'." |
| 294 | (if (not function) | 308 | (if (not function) |
| 295 | (error "You didn't specify a function")) | 309 | (error "You didn't specify a function")) |
| 296 | (let ((def (symbol-function function)) | 310 | (let ((def (symbol-function (find-function-advised-original function))) |
| 297 | aliases) | 311 | aliases) |
| 312 | ;; FIXME for completeness, it might be nice to print something like: | ||
| 313 | ;; foo (which is advised), which is an alias for bar (which is advised). | ||
| 298 | (while (symbolp def) | 314 | (while (symbolp def) |
| 299 | (or (eq def function) | 315 | (or (eq def function) |
| 300 | (if aliases | 316 | (if aliases |
| 301 | (setq aliases (concat aliases | 317 | (setq aliases (concat aliases |
| 302 | (format ", which is an alias for `%s'" | 318 | (format ", which is an alias for `%s'" |
| 303 | (symbol-name def)))) | 319 | (symbol-name def)))) |
| 304 | (setq aliases (format "`%s' an alias for `%s'" | 320 | (setq aliases (format "`%s' is an alias for `%s'" |
| 305 | function (symbol-name def))))) | 321 | function (symbol-name def))))) |
| 306 | (setq function (symbol-function function) | 322 | (setq function (symbol-function (find-function-advised-original function)) |
| 307 | def (symbol-function function))) | 323 | def (symbol-function (find-function-advised-original function)))) |
| 308 | (if aliases | 324 | (if aliases |
| 309 | (message "%s" aliases)) | 325 | (message "%s" aliases)) |
| 310 | (let ((library | 326 | (let ((library |