Function: consult-xref

consult-xref is an autoloaded and byte-compiled function defined in consult-xref.el.

Signature

(consult-xref FETCHER &optional ALIST)

Documentation

Show xrefs with preview in the minibuffer.

This function can be used for xref-show-xrefs-function. See xref-show-xrefs-function for the description of the FETCHER and ALIST arguments.

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult-xref.el
;;;###autoload
(defun consult-xref (fetcher &optional alist)
  "Show xrefs with preview in the minibuffer.

This function can be used for `xref-show-xrefs-function'.
See `xref-show-xrefs-function' for the description of the
FETCHER and ALIST arguments."
  (let* ((consult-xref--fetcher fetcher)
         (candidates (consult-xref--candidates))
         (display (alist-get 'display-action alist)))
    (unless candidates
      (user-error "No xref locations"))
    (xref-pop-to-location
     (if (cdr candidates)
         (consult--read
          candidates
          :command #'consult-xref
          :prompt "Go to xref: "
          :history 'consult-xref--history
          :require-match t
          :sort nil
          :category 'consult-xref
          :group #'consult--prefix-group
          :state
          ;; do not preview other frame
          (when-let* ((fun (pcase-exhaustive display
                             ('frame nil)
                             ('window #'switch-to-buffer-other-window)
                             ('nil #'switch-to-buffer))))
            (consult-xref--preview fun))
          :lookup (apply-partially #'consult--lookup-prop 'consult-xref))
       (get-text-property 0 'consult-xref (car candidates)))
     display)))