help-setup-xref: Keep the local values only of some variables

* lisp/help-mode.el (help-setup-xref): Kill all local variables,
saving ones that are known to need to be preserved (bug#73637).
This commit is contained in:
Dmitry Gutov 2024-10-06 04:31:31 +03:00
parent 4c7a6dc1a0
commit e776df2a3e

View file

@ -505,30 +505,19 @@ This should be called very early, before the output buffer is cleared,
because we want to record the \"previous\" position of point so we can
restore it properly when going back."
(with-current-buffer (help-buffer)
;; Disable `outline-minor-mode' in a reused Help buffer
;; created by `describe-bindings' that enables this mode.
(when (bound-and-true-p outline-minor-mode)
(outline-minor-mode -1)
(mapc #'kill-local-variable
'(outline-search-function
outline-regexp
outline-heading-end-regexp
outline-level
outline-minor-mode-cycle
outline-minor-mode-highlight
outline-minor-mode-use-buttons
outline-default-state
outline-default-rules)))
(kill-local-variable 'xref-backend-functions)
(kill-local-variable 'semantic-symref-filepattern-alist)
(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)))
(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))))
(defvar help-xref-following nil
"Non-nil when following a help cross-reference.")