7.7 Definitions and References

Sweep Prolog mode integrates with the Emacs xref API to facilitate quick access to predicate definitions and references in Prolog code buffers. This enables the many commands that the xref interface provides, like M-. (xref-find-definitions) for jumping to the definition of the predicate at point. See (emacs)Find Identifiers, for an overview of the available commands.

Sweep Prolog mode also integrates with Emacs’s imenu, which provides a simple facility for looking up and jumping to definitions in the current buffer. To jump to a definition in the current buffer, type M-x imenu RET (bound by default to M-g i in Emacs version 29 or later). For information about customizing imenu, (emacs)Imenu.

You can use the command sweeprolog-xref-project-source-files to update Sweep’s cross reference data for all Prolog source files in the current project. To determine the set of source files in the current project, Sweep consults the functions project-current and project-files (see (emacs)Projects). When you search for references to Prolog predicates with M-? (xref-find-references), Sweep implicitly invokes sweeprolog-xref-project-source-files to bring you up-to-date references from across the current project.