From: Stefan Monnier Date: Sun, 2 Feb 2014 02:25:05 +0000 (-0500) Subject: * lisp/help-fns.el (help-C-file-name): Handle advised functions. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~198 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=70e5a261ac4e923a09a464af9ffb9a321a42e70e;p=emacs.git * lisp/help-fns.el (help-C-file-name): Handle advised functions. * lisp/emacs-lisp/find-func.el (find-function-C-source): Idem. * lisp/emacs-lisp/nadvice.el (advice--cd*r): New function. * help-fns.el (describe-function-1): Use it. Fixes: debbugs:16478 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 11952ba98ee..6471005cf8d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-02-02 Stefan Monnier + + * help-fns.el (help-C-file-name): Handle advised functions (bug#16478). + * emacs-lisp/find-func.el (find-function-C-source): Idem. + * emacs-lisp/nadvice.el (advice--cd*r): New function. + * help-fns.el (describe-function-1): Use it. + 2014-02-02 Glenn Morris * register.el (register-preview-default): New function, @@ -35,8 +42,8 @@ (ruby-smie-grammar): Make "." right-associative. Make its priority lower than the ternary and all binary operators. (ruby-smie-rules): Indent "(" relative to the first non-"." - parent, or the first "." parent at indentation. Use - `ruby-align-chained-calls' for indentation of "." tokens. + parent, or the first "." parent at indentation. + Use `ruby-align-chained-calls' for indentation of "." tokens. (Bug#16593) 2014-01-31 Juri Linkov diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 31e9be81034..5c404ce0468 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -219,7 +219,7 @@ TYPE should be nil to find a function, or `defvar' to find a variable." (regexp-quote (symbol-name fun-or-var)) "\"") (concat "DEFUN[ \t\n]*([ \t\n]*\"" - (regexp-quote (subr-name fun-or-var)) + (regexp-quote (subr-name (advice--cd*r fun-or-var))) "\"")) nil t) (error "Can't find source for %s" fun-or-var)) diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 3dfeb04a9b3..8dc1f19784c 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -67,6 +67,11 @@ Each element has the form (WHERE BYTECODE STACK) where: (defsubst advice--cdr (f) (aref (aref f 2) 2)) (defsubst advice--props (f) (aref (aref f 2) 3)) +(defun advice--cd*r (f) + (while (advice--p f) + (setq f (advice--cdr f))) + f) + (defun advice--make-docstring (function) "Build the raw docstring for FUNCTION, presumably advised." (let ((flist (indirect-function function)) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 2252c700fea..5e38de88f72 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -187,7 +187,7 @@ KIND should be `var' for a variable or `subr' for a subroutine." (let ((docbuf (get-buffer-create " *DOC*")) (name (if (eq 'var kind) (concat "V" (symbol-name subr-or-var)) - (concat "F" (subr-name subr-or-var))))) + (concat "F" (subr-name (advice--cd*r subr-or-var)))))) (with-current-buffer docbuf (goto-char (point-min)) (if (eobp) @@ -542,11 +542,7 @@ FILE is the file where FUNCTION was probably defined." ;; real definition, if that symbol is already set up. (real-function (or (and advised - (let* ((advised-fn (advice--cdr - (advice--symbol-function function)))) - (while (advice--p advised-fn) - (setq advised-fn (advice--cdr advised-fn))) - advised-fn)) + (advice--cd*r (advice--symbol-function function))) function)) ;; Get the real definition. (def (if (symbolp real-function) @@ -660,9 +656,9 @@ FILE is the file where FUNCTION was probably defined." (or doc "Not documented."))))))) ;; Add defaults to `help-fns-describe-function-functions'. -(add-hook 'help-fns-describe-function-functions 'help-fns--obsolete) -(add-hook 'help-fns-describe-function-functions 'help-fns--parent-mode) -(add-hook 'help-fns-describe-function-functions 'help-fns--compiler-macro) +(add-hook 'help-fns-describe-function-functions #'help-fns--obsolete) +(add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode) +(add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro) ;; Variables