ELPA Logo GNU ELPA: xref

xref Atom Feed

Description
Cross-referencing commands
Latest
xref.tar (.sig), 2026-Sep-06, 0.03 KiB
Maintainer
Other versions:
development version
Website
https://elpa.gnu.org/nongnu/xref.html
Repository
CGit or Gitweb
Badge

To install this package from Emacs, use list-packages.

Full description

This file provides a generic infrastructure for cross referencing
commands, such as "find definition".

The unique functionality is configured by defining an xref backend.
That consists of a constructor function, and implementations for the
generic functions (using `cl-defmethod').

The constructor should return a value that `cl-defmethod' can
dispatch on.  Most often it is a plain symbol, such as `elisp'.
A major or minor mode would use `add-hook' to set itself up and add
the backend constructor to `xref-backend-functions'.

Some important backend methods to define are:

`xref-backend-identifier-at-point',
`xref-backend-identifier-completion-table',
`xref-backend-definitions', `xref-backend-references',
`xref-backend-apropos'.

And more optional ones:

`xref-backend-identifier-completion-ignore-case',
`xref-backend-identifier-completion-predicate',
`xref-backend-xref-kinds' and `xref-backend-xrefs-by-kind'.

The methods which return a list of results (such as "definitions")
operate with "xref" and "location" values.  Locations are values that
also can be dispatched on by `cl-defmethod', usually cl-structs.

One would usually call `xref-make' and `xref-make-file-location',
`xref-make-buffer-location' or `xref-make-bogus-location' to create
them.  The latter functions correspond to built-in location types.

More generally, a location must also be values that `cl-defmethod'
can dispatch on, usually cl-structs.  Each of them implements
`xref-location-group' and `xref-location-marker'.
`xref-location-line' is optional.

There is a special category of xrefs we call "match xrefs", which
correspond to search results that have spans.  For these values,
`xref-match-length' must be defined, and `xref-location-marker' must
return the beginning of the match.

Each identifier must be represented as a string.  Definitions can use
string properties to store additional information about the
identifier, but strings in `xref-backend-identifier-completion-table'
should still be distinct, because the user can't see the text
properties when making the choice.

Older versions of Xref used EIEIO for implementation of the
built-in types, and included a class called `xref-location' which
was supposed to be inherited from.  Neither is true anymore.

See the implementations in `elisp-mode', `eglot' and `etags' for more
complete examples.

Old versions

xref-1.7.0.0.20260906.47.tar.lz2026-Sep-0623.7 KiB
xref-1.7.0.0.20260906.47.tar2026-Sep-06 110 KiB
xref-1.7.0.0.20260904.46.tar.lz2026-Sep-0423.7 KiB
xref-1.7.0.0.20260902.45.tar.lz2026-Sep-0323.5 KiB
xref-1.7.0.0.20260831.44.tar.lz2026-Sep-0223.5 KiB
xref-1.7.0.0.20260403.13314.tar.lz2026-Apr-0322.7 KiB
xref-1.7.0.0.20260313.230302.tar.lz2026-Mar-1421.9 KiB
xref-1.7.0.0.20251018.61546.tar.lz2025-Oct-1821.2 KiB
xref-1.6.3.0.20240525.230313.tar.lz2024-May-2620.8 KiB
xref-1.5.1.0.20221123.182545.tar.lz2022-Nov-2319.8 KiB
xref-1.4.1.0.20220620.4414.tar.lz2022-Jun-2019.5 KiB
xref-1.0.4.0.20210424.95444.tar.lz2021-Apr-2416.6 KiB