Subject: Re: bug#73686: 31.0.50; ERC 5.6.1-git: back button gone from describe-face via erc-nicks-list-faces

From: "J.P." <[email-masked]>
Date: Mon, 07 Oct 2024 23:06:20 -0700

"J.P." <[email-masked]> writes:

> This appears to be related to a recent change involving the killing of
> local variables in `help-setup-xref'.

Poking around some, it seems the various `describe-*' commands in
help-fns.el run `help-setup-xref' before doing

  (with-help-window (help-buffer) ...)

And because `major-mode' is buffer-local, it gets wiped out with these
latest changes before `help-buffer' ever sees it:

  (defun help-buffer ()
    (buffer-name
     (if (and help-xref-following
              (derived-mode-p 'help-mode))
         (current-buffer)
       (get-buffer-create "*Help*"))))

(Here, `help-xref-following' is t thanks to `help-do-xref'.)

> Regarding (2), the Help buffer now opens in a split whereas before it
> opened in the current window. The failing test expects the old behavior

This appears to happen when the `help-mode' (turned `fundamental-mode')
buffer from which `describe-*' is run isn't named `*Help*', as is the
case with `list-faces-display' and `erc-nicks-list-faces'.

As for fixing this, I wonder if we can somehow expand the role of
`help-buffer-under-preparation' (or `help-xref-following') so that
instead of t, it's bound to the last value of `major-mode' prior to
`help-setup-xref' running. And then `help-buffer' could first check this
stashed value before considering the current `major-mode' (like via
`provided-mode-derived-p' or whatever).