Subject: bug#73637: [PATCH] New hook 'help-setup-hook'

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Oct 2024 10:40:56 +0300

> Date: Sat, 05 Oct 2024 09:14:54 +0200
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>

Stefan, any comments?

> --- a/lisp/help-fns.el
> +++ b/lisp/help-fns.el
> @@ -280,7 +280,12 @@ xref-backend-references
>  
>  (defun help-fns--setup-xref-backend ()
>    (add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
> -  (setq-local semantic-symref-filepattern-alist '((help-mode "*.el"))))
> +  (setq-local semantic-symref-filepattern-alist '((help-mode "*.el")))
> +  (add-hook 'help-setup-hook
> +            (lambda ()
> +              (kill-local-variable 'xref-backend-functions)
> +              (kill-local-variable 'semantic-symref-filepattern-alist))
> +            nil t))

Please add comments here to explain why the hook does these things.

> --- a/lisp/help-mode.el
> +++ b/lisp/help-mode.el
> @@ -492,6 +492,13 @@ help-xref-url-regexp
>    (purecopy "\\<[Uu][Rr][Ll][ \t\n]+['`‘]\\([^'’]+\\)['’]")
>    "Regexp matching doc string references to a URL.")
>  
> +(defvar-local help-setup-hook nil
> +  "Functions to call with no arguments when populating \"*Help*\" buffers.

Please mention in the doc string which function(s) call(s) this hook.

> -    ;; Disable `outline-minor-mode' in a reused Help buffer
> -    ;; created by `describe-bindings' that enables this mode.

This useful comment is lost as result of your patch.  Is that on
purpose?

Finally, I think this hook should be added to the list of the standard
hooks in the ELisp manual.

Thanks.