Subject: Re: bug#33830: 27.0.50; help-xref-stack contains bad entries

From: Federico Tedin <[email-masked]>
Date: Thu, 27 Dec 2018 19:38:59 -0300

Alex Branham <[email-masked]> writes:

> Sometimes `help-xref-stack' contains "bad" entries, which makes
> help-go-forward and help-go-back error in a strange way. To see what I
> mean:
>
> emacs -q
>
> C-h f car RET
> C-h k C-x t
> C-h f cdr RET
>
> Now that the *Help* buffer is displaying `cdr', if you try to go back
> (with "l" or clicking the back button), you get "user-error C-x t is
> undefined".
>
> Alex

I've noticed that the `describe-key' and `describe-function' functions both
call `help-setup-xref' with key sequences and functions respectively,
even if said key sequences or functions are not valid (i.e. when the key
sequence isn't bound to anything and the function does not exist).

An example of this:

1) M-:: (describe-function 'hello) RET
2) C-h f car RET
3) On the *Help* buffer, press 'l'

The message 'Symbol’s function definition is void: hello' will be
displayed, and the *Help* buffer will contain "hello is ". Also, for
some reason, after pressing 'r', two [back] buttons will be shown.

Maybe `help-setup-xref' should only be called when it is certain that
the key sequence/function/etc. exists?

(tested on master branch)