Skip to content

Commit 04cad13

Browse files
xiongtxbbatsov
authored andcommitted
Factor out back/forward button parts from cider--doc-make-xrefs
1 parent 01d4ac8 commit 04cad13

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

cider-util.el

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,26 @@ the buffer."
473473
(declare-function cider-doc-lookup "cider-doc")
474474
(declare-function cider--eldoc-remove-dot "cider-eldoc")
475475

476+
;; Taken from: https://github.com/emacs-mirror/emacs/blob/65c8c7cb96c14f9c6accd03cc8851b5a3459049e/lisp/help-mode.el#L551-L565
477+
(defun cider--make-back-forward-xrefs (&optional buffer)
478+
"Insert special references `back' and `forward', as in `help-make-xrefs'"
479+
(with-current-buffer (or buffer (current-buffer))
480+
(insert "\n")
481+
(when (or help-xref-stack help-xref-forward-stack)
482+
(insert "\n"))
483+
;; Make a back-reference in this buffer if appropriate.
484+
(when help-xref-stack
485+
(help-insert-xref-button help-back-label 'help-back
486+
(current-buffer)))
487+
;; Make a forward-reference in this buffer if appropriate.
488+
(when help-xref-forward-stack
489+
(when help-xref-stack
490+
(insert "\t"))
491+
(help-insert-xref-button help-forward-label 'help-forward
492+
(current-buffer)))
493+
(when (or help-xref-stack help-xref-forward-stack)
494+
(insert "\n"))))
495+
476496
;; Similar to https://github.com/emacs-mirror/emacs/blob/65c8c7cb96c14f9c6accd03cc8851b5a3459049e/lisp/help-mode.el#L404
477497
(defun cider--doc-make-xrefs ()
478498
"Parse and hyperlink documentation cross-references in current buffer.
@@ -495,23 +515,7 @@ through a stack of help buffers. Variables `help-back-label' and
495515
'type 'help-xref
496516
'help-function (apply-partially #'cider-doc-lookup
497517
(cider--eldoc-remove-dot symbol))))))
498-
499-
;; create back and forward buttons if appropiate
500-
(insert "\n")
501-
(when (or help-xref-stack help-xref-forward-stack)
502-
(insert "\n"))
503-
;; Make a back-reference in this buffer if appropriate.
504-
(when help-xref-stack
505-
(help-insert-xref-button help-back-label 'help-back
506-
(current-buffer)))
507-
;; Make a forward-reference in this buffer if appropriate.
508-
(when help-xref-forward-stack
509-
(when help-xref-stack
510-
(insert "\t"))
511-
(help-insert-xref-button help-forward-label 'help-forward
512-
(current-buffer)))
513-
(when (or help-xref-stack help-xref-forward-stack)
514-
(insert "\n")))
518+
(cider--make-back-forward-xrefs))
515519

516520

517521
;;; Words of inspiration

0 commit comments

Comments
 (0)