Let describe-function work for lambda again

Since commit "* lisp/help-fns.el (describe-function): More type
checking[...]", `describe-function' throws a user-error when given a
non-symbol.  This prevents the [back] button in a *Help* buffer from
working when the page it goes back to describes an anonymous
function (e.g., the result of `describe-key' on a key which is bound to
a lambda form).

* lisp/help-fns.el (describe-function): Move the checks on FUNCTION
being an fbound symbol into the `interactive' form.  This allows
non-interactive calls to pass an anonymous function (Bug #24221).  Note
that passing a non-bound symbol non-interactively will still trigger a
`void-function' error from `describe-function-1'.
This commit is contained in:
Noam Postavsky 2016-10-03 18:49:56 -04:00
parent 5c2da93015
commit 9da53e2d35

View file

@ -50,23 +50,24 @@ to get buffer-local values.")
;;;###autoload ;;;###autoload
(defun describe-function (function) (defun describe-function (function)
"Display the full documentation of FUNCTION (a symbol)." "Display the full documentation of FUNCTION (a symbol).
When called from lisp, FUNCTION may also be a function object."
(interactive (interactive
(let ((fn (function-called-at-point)) (let* ((fn (function-called-at-point))
(enable-recursive-minibuffers t) (enable-recursive-minibuffers t)
val) (val (completing-read
(setq val (completing-read (if fn (if fn
(format "Describe function (default %s): " fn) (format "Describe function (default %s): " fn)
"Describe function: ") "Describe function: ")
obarray 'fboundp t nil nil obarray 'fboundp t nil nil
(and fn (symbol-name fn)))) (and fn (symbol-name fn)))))
(list (if (equal val "") (unless (equal val "")
fn (intern val))))) (setq fn (intern val)))
(or (and function (symbolp function)) (unless (and fn (symbolp fn))
(user-error "You didn't specify a function symbol")) (user-error "You didn't specify a function symbol"))
(or (fboundp function) (unless (fboundp fn)
(user-error "Symbol's function definition is void: %s" function)) (user-error "Symbol's function definition is void: %s" fn))
(list fn)))
;; We save describe-function-orig-buffer on the help xref stack, so ;; We save describe-function-orig-buffer on the help xref stack, so
;; it is restored by the back/forward buttons. 'help-buffer' ;; it is restored by the back/forward buttons. 'help-buffer'
;; expects (current-buffer) to be a help buffer when processing ;; expects (current-buffer) to be a help buffer when processing