emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9b5eb661bf 1/2: Fix xref links in `C-h o'


From: Lars Ingebrigtsen
Subject: master 9b5eb661bf 1/2: Fix xref links in `C-h o'
Date: Sat, 16 Jul 2022 12:27:05 -0400 (EDT)

branch: master
commit 9b5eb661bf01d5b7e3453011b93f0eaf8621521e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 lisp/help-fns.el  |  8 ++++++--
 lisp/help-mode.el | 31 +++++++++++++++++--------------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 85984c87e2..aceac1f275 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 8b5e48edad..e374f8e94d 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]