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

From: [email-masked] (Peder O. Klingenberg)
Date: Sun, 28 Aug 2016 22:07:57 +0200

Zachary Kanfer <[email-masked]> writes:

> emacs -Q
>
> Evaluate this code:
>
> (global-set-key (kbd "C-c l") (lambda () (interactive) (insert "This
> messes up the help buffer somehow.")))
>
> Then open up a help buffer for that function:
>
> C-h k C-c l
>
> And a help buffer for something else:
>
> C-h k a
>
> Then, in the help buffer, go to the bottom, and try to select the
> "[back]" link. I get an error: "user-error: You didn’t specify a function
> symbol". If I try again, I get a different error: "apply: Symbol’s
> function definition is void: nil". These errors happen whether I've
> select the link with pressing Enter on the keyboard or by clicking the
> mouse.

I can confirm this.  Here's what I think is happening:

`describe-key' (C-h k) finds your lambda expression when it calls
`key-binding'.  It then pushes this lambda on the help-xref-stack as an
argument to `describe-function'.  But `describe-function' doesn't know
what to do with a lamda expression, and gives you that "You didn't
specify a function symbol" message when the xref stack is popped and
`describe-function' is called.

I don't know what the best fix would be - fix the xref setup in
`describe-key' or teach `describe-function' to do something useful with
a lambda expression.