Commit faec28d9 authored by Tassilo Horn's avatar Tassilo Horn
Browse files

Fix describe-function with advised functions.

* lisp/help-fns.el (describe-function-1): Use new advice-* functions
rather than old ad-* functions.  Fix function type description and
source links for advised functions and subrs.
parent 1bb2debd
2013-12-07 Tassilo Horn <tsdh@gnu.org>
* help-fns.el (describe-function-1): Use new advice-* functions
rather than old ad-* functions. Fix function type description and
source links for advised functions and subrs.
2013-12-07 Lars Magne Ingebrigtsen <larsi@gnus.org> 2013-12-07 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-tag-img): Don't bug out on <img src=""> * net/shr.el (shr-tag-img): Don't bug out on <img src="">
......
...@@ -382,8 +382,6 @@ suitable file is found, return nil." ...@@ -382,8 +382,6 @@ suitable file is found, return nil."
(match-string 1 str)))) (match-string 1 str))))
(and src-file (file-readable-p src-file) src-file)))))) (and src-file (file-readable-p src-file) src-file))))))
(declare-function ad-get-advice-info "advice" (function))
(defun help-fns--key-bindings (function) (defun help-fns--key-bindings (function)
(when (commandp function) (when (commandp function)
(let ((pt2 (with-current-buffer standard-output (point))) (let ((pt2 (with-current-buffer standard-output (point)))
...@@ -531,27 +529,34 @@ FILE is the file where FUNCTION was probably defined." ...@@ -531,27 +529,34 @@ FILE is the file where FUNCTION was probably defined."
;;;###autoload ;;;###autoload
(defun describe-function-1 (function) (defun describe-function-1 (function)
(let* ((advised (and (symbolp function) (featurep 'advice) (let* ((advised (and (symbolp function)
(ad-get-advice-info function))) (featurep 'nadvice)
(advice--p (advice--symbol-function function))))
;; If the function is advised, use the symbol that has the ;; If the function is advised, use the symbol that has the
;; real definition, if that symbol is already set up. ;; real definition, if that symbol is already set up.
(real-function (real-function
(or (and advised (or (and advised
(let ((origname (cdr (assq 'origname advised)))) (let* ((advised-fn (advice--cdr
(and (fboundp origname) origname))) (advice--symbol-function function))))
(while (advice--p advised-fn)
(setq advised-fn (advice--cdr advised-fn)))
advised-fn))
function)) function))
;; Get the real definition. ;; Get the real definition.
(def (if (symbolp real-function) (def (if (symbolp real-function)
(symbol-function real-function) (symbol-function real-function)
function)) real-function))
(aliased (symbolp def)) (aliased (or (symbolp def)
(real-def (if aliased ;; Advised & aliased function.
(let ((f def)) (and advised (symbolp real-function))))
(while (and (fboundp f) (real-def (cond
(symbolp (symbol-function f))) (aliased (let ((f real-function))
(setq f (symbol-function f))) (while (and (fboundp f)
f) (symbolp (symbol-function f)))
def)) (setq f (symbol-function f)))
f))
((subrp def) (intern (subr-name def)))
(t def)))
(file-name (find-lisp-object-file-name function def)) (file-name (find-lisp-object-file-name function def))
(pt1 (with-current-buffer (help-buffer) (point))) (pt1 (with-current-buffer (help-buffer) (point)))
(beg (if (and (or (byte-code-function-p def) (beg (if (and (or (byte-code-function-p def)
...@@ -571,14 +576,20 @@ FILE is the file where FUNCTION was probably defined." ...@@ -571,14 +576,20 @@ FILE is the file where FUNCTION was probably defined."
(if (eq 'unevalled (cdr (subr-arity def))) (if (eq 'unevalled (cdr (subr-arity def)))
(concat beg "special form") (concat beg "special form")
(concat beg "built-in function"))) (concat beg "built-in function")))
((byte-code-function-p def) ;; Aliases are Lisp functions, so we need to check
(concat beg "compiled Lisp function")) ;; aliases before functions.
(aliased (aliased
(format "an alias for `%s'" real-def)) (format "an alias for `%s'" real-def))
((or (eq (car-safe def) 'macro)
;; For advised macros, def is a lambda
;; expression or a byte-code-function-p, so we
;; need to check macros before functions.
(macrop function))
(concat beg "Lisp macro"))
((byte-code-function-p def)
(concat beg "compiled Lisp function"))
((eq (car-safe def) 'lambda) ((eq (car-safe def) 'lambda)
(concat beg "Lisp function")) (concat beg "Lisp function"))
((eq (car-safe def) 'macro)
(concat beg "Lisp macro"))
((eq (car-safe def) 'closure) ((eq (car-safe def) 'closure)
(concat beg "Lisp closure")) (concat beg "Lisp closure"))
((autoloadp def) ((autoloadp def)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment