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

From: Dmitry Gutov <[email-masked]>
Date: Sun, 6 Oct 2024 17:41:02 +0300

On 06/10/2024 09:56, Juri Linkov wrote:
>> Great! I've pushed that patch, please report any new regressions.
> Maybe 'help-xref-forward-stack' and 'help-xref-stack-forward-item'
> should be preserved as well?

Good question - looks like both of these vars are marked as 
'permanent-local' already. And the ones I set up to be restored are too.

This suggests a further simplification, pushed to master now:

diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index a44749d1fe9..4ee4f4156a1 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -505,19 +505,15 @@ help-setup-xref
  because we want to record the \"previous\" position of point so we can
  restore it properly when going back."
    (with-current-buffer (help-buffer)
-    (let ((stack-item help-xref-stack-item)
-          (stack help-xref-stack))
-      (kill-all-local-variables)
-      (setq help-xref-stack-item stack-item
-            help-xref-stack stack)
-      (when help-xref-stack-item
-        (push (cons (point) help-xref-stack-item) help-xref-stack)
-        (setq help-xref-forward-stack nil))
-      (when interactive-p
-        (let ((tail (nthcdr 10 help-xref-stack)))
-      ;; Truncate the stack.
-      (if tail (setcdr tail nil))))
-      (setq help-xref-stack-item item))))
+    (kill-all-local-variables)
+    (when help-xref-stack-item
+      (push (cons (point) help-xref-stack-item) help-xref-stack)
+      (setq help-xref-forward-stack nil))
+    (when interactive-p
+      (let ((tail (nthcdr 10 help-xref-stack)))
+        ;; Truncate the stack.
+        (if tail (setcdr tail nil))))
+    (setq help-xref-stack-item item)))

  (defvar help-xref-following nil
    "Non-nil when following a help cross-reference.")