Subject: bug#24221: 25.1.50; binding anonymous functions to keys cause help buffer navigation errors

From: Drew Adams <[email-masked]>
Date: Sat, 17 Sep 2016 11:28:47 -0700 (PDT)

I suggest using code such as that below - allow FUNCTION to be
`functionp', not only a symbol that is `fboundp' (and test for
the former first).

Also, the function that raises an error should be `user-error'
only when called interactively.  Otherwise, it should be `error'.

[I would even argue that for interactive use it should be
`message', not `user-error', as that allows `describe-function'
to be used, e.g., in the minibuffer to get help on different
function-name candidates.]

(let* ((interactivep  (called-interactively-p 'interactive))
       (err-fn        (if interactivep #user-error #'error)))
  (if (and interactivep  (not function))
      (funcall err-fn "You did not specify a function symbol")
    (if (not (or (functionp function) ; Allow anonymous functions.
                 (and function   ; Allow macros and special forms.
                      (fboundp (intern-soft function))))))
        (funcall err-fn "Not a defined function: `%S'" function)
    (help-setup-xref ...)
    ...)