]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix xref links in `C-h o'
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 16 Jul 2022 12:57:58 +0000 (14:57 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 16 Jul 2022 16:26:58 +0000 (18:26 +0200)
* 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.

lisp/help-fns.el
lisp/help-mode.el

index 85984c87e2db71d4eb8db0771f089c8a389c2b21..aceac1f2756d135d8a33275e58e81b67af4ff1bb 100644 (file)
@@ -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
index 8b5e48edad13b7ff5fecd8cf3a29d799c9d65562..e374f8e94def9c9608566e1290e0a8bea311e77d 100644 (file)
@@ -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.