Function: help-setup-xref
help-setup-xref is an autoloaded and byte-compiled function defined in
help-mode.el.gz.
Signature
(help-setup-xref ITEM INTERACTIVE-P)
Documentation
Invoked from commands using the "*Help*" buffer to install some xref info.
ITEM is a (FUNCTION . ARGS) pair appropriate for recreating the help buffer after following a reference. INTERACTIVE-P is non-nil if the calling command was invoked interactively. In this case the stack of items for help buffer "back" buttons is cleared.
This function also re-enables the major mode of the buffer, thus resetting local variables to the values set by the mode and running the mode hooks.
So this should be called very early, before the output buffer is cleared, also because we want to record the "previous" position of point so we can restore it properly when going back.
Probably introduced at or before Emacs version 31.1.
Source Code
;; Defined in /usr/src/emacs/lisp/help-mode.el.gz
;;;###autoload
(defun help-setup-xref (item interactive-p)
"Invoked from commands using the \"*Help*\" buffer to install some xref info.
ITEM is a (FUNCTION . ARGS) pair appropriate for recreating the help
buffer after following a reference. INTERACTIVE-P is non-nil if the
calling command was invoked interactively. In this case the stack of
items for help buffer \"back\" buttons is cleared.
This function also re-enables the major mode of the buffer, thus
resetting local variables to the values set by the mode and running the
mode hooks.
So this should be called very early, before the output buffer is
cleared, also because we want to record the \"previous\" position of
point so we can restore it properly when going back."
(with-current-buffer (help-buffer)
;; Re-enable major mode, killing all unrelated local vars.
(funcall major-mode)
(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)))