* lisp/help-fns.el (describe-function-1):

Fix help-fns-test-dangling-alias.  (Bug#28918)

(cherry picked from commit e1d42f8f4a)
This commit is contained in:
Stefan Monnier 2017-10-20 16:04:02 -04:00 committed by Glenn Morris
parent 11bd8aa24b
commit ef3d8505ec

View file

@ -561,6 +561,8 @@ FILE is the file where FUNCTION was probably defined."
short)) short))
(defun help-fns--analyse-function (function) (defun help-fns--analyse-function (function)
;; FIXME: Document/explain the differences between FUNCTION,
;; REAL-FUNCTION, DEF, and REAL-DEF.
"Return information about FUNCTION. "Return information about FUNCTION.
Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)." Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
(let* ((advised (and (symbolp function) (let* ((advised (and (symbolp function)
@ -689,10 +691,15 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
(point)))) (point))))
(terpri)(terpri) (terpri)(terpri)
(pcase-let ((`(,real-function ,def ,_aliased ,real-def) (pcase-let* ((`(,real-function ,def ,_aliased ,real-def)
(help-fns--analyse-function function)) (help-fns--analyse-function function))
(doc-raw (documentation function t)) (doc-raw (condition-case nil
(key-bindings-buffer (current-buffer))) ;; FIXME: Maybe `documentation' should return nil
;; for invalid functions i.s.o. signaling an error.
(documentation function t)
;; E.g. an alias for a not yet defined function.
(invalid-function nil)))
(key-bindings-buffer (current-buffer)))
;; If the function is autoloaded, and its docstring has ;; If the function is autoloaded, and its docstring has
;; key substitution constructs, load the library. ;; key substitution constructs, load the library.
@ -703,10 +710,15 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
(help-fns--key-bindings function) (help-fns--key-bindings function)
(with-current-buffer standard-output (with-current-buffer standard-output
(let ((doc (help-fns--signature (let ((doc (condition-case nil
function doc-raw ;; FIXME: Maybe `help-fns--signature' should return `doc'
(if (subrp def) (indirect-function real-def) real-def) ;; for invalid functions i.s.o. signaling an error.
real-function key-bindings-buffer))) (help-fns--signature
function doc-raw
(if (subrp def) (indirect-function real-def) real-def)
real-function key-bindings-buffer)
;; E.g. an alias for a not yet defined function.
(invalid-function doc-raw))))
(run-hook-with-args 'help-fns-describe-function-functions function) (run-hook-with-args 'help-fns-describe-function-functions function)
(insert "\n" (or doc "Not documented."))) (insert "\n" (or doc "Not documented.")))
;; Avoid asking the user annoying questions if she decides ;; Avoid asking the user annoying questions if she decides