From: Lars Ingebrigtsen Date: Sat, 16 Jul 2022 12:57:58 +0000 (+0200) Subject: Fix xref links in `C-h o' X-Git-Tag: emacs-29.0.90~1447^2~892 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9b5eb661bf01d5b7e3453011b93f0eaf8621521e;p=emacs.git Fix xref links in `C-h o' * lisp/help-fns.el (describe-symbol): Make xref links happen in all sections (bug#49587). * lisp/help-fns.el (describe-symbol): Add back/forward links. * lisp/help-mode.el (help-make-xrefs): Factor out links from here... (help-xref--navigation-buttons): To here. --- diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 85984c87e2d..aceac1f2756 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1800,8 +1800,10 @@ current buffer and the selected frame, respectively." (when (funcall testfn symbol) ;; Don't record the current entry in the stack. (setq help-xref-stack-item nil) - (cons name - (funcall descfn symbol buffer frame)))) + (let ((help-xref-stack nil) + (help-xref-forward-stack nil)) + (funcall descfn symbol buffer frame)) + (cons name (buffer-string)))) describe-symbol-backends)))) (single (null (cdr docs)))) (while (cdr docs) @@ -1822,6 +1824,8 @@ current buffer and the selected frame, respectively." ;; Don't record the `describe-variable' item in the stack. (setq help-xref-stack-item nil) (help-setup-xref (list #'describe-symbol symbol) nil)) + (goto-char (point-max)) + (help-xref--navigation-buttons) (goto-char (point-min)))))) ;;;###autoload diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 8b5e48edad1..e374f8e94de 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -673,22 +673,25 @@ that." (while (and (not (bobp)) (bolp)) (delete-char -1)) (insert "\n") - (when (or help-xref-stack help-xref-forward-stack) - (insert "\n")) - ;; Make a back-reference in this buffer if appropriate. - (when help-xref-stack - (help-insert-xref-button help-back-label 'help-back - (current-buffer))) - ;; Make a forward-reference in this buffer if appropriate. - (when help-xref-forward-stack - (when help-xref-stack - (insert "\t")) - (help-insert-xref-button help-forward-label 'help-forward - (current-buffer))) - (when (or help-xref-stack help-xref-forward-stack) - (insert "\n"))) + (help-xref--navigation-buttons)) (set-buffer-modified-p old-modified))))) +(defun help-xref--navigation-buttons () + (let ((inhibit-read-only t)) + ;; Make a back-reference in this buffer if appropriate. + (when help-xref-stack + (ensure-empty-lines 1) + (help-insert-xref-button help-back-label 'help-back + (current-buffer))) + ;; Make a forward-reference in this buffer if appropriate. + (when help-xref-forward-stack + (when help-xref-stack + (insert "\t")) + (help-insert-xref-button help-forward-label 'help-forward + (current-buffer))) + (unless (bolp) + (insert "\n")))) + ;;;###autoload (defun help-xref-button (match-number type &rest args) "Make a hyperlink for cross-reference text previously matched.