7.18 Code Completion

In Emacs, major modes for different programming languages provide in-buffer code completion via a standard generic command called completion-at-point (see (emacs)Symbol Completion). This command is normally bound to C-M-i and M-TAB. Sweep extends completion-at-point with context-aware completion for Prolog code in Prolog buffers.

When providing candidates for in-buffer completion, Sweep takes into account the code surrounding the cursor to determine what kind of completion makes most sense:

Variable name completion

If the text before point can be completed to one or more variable names that appear elsewhere in the current clause, completion-at-point suggests matching variable names as completion candidates.

Predicate completion

If point is at a callable position, completion-at-point suggests matching predicate calls as completion candidates. If the predicate you choose takes arguments, Sweep inserts holes in their places, and moves point to the first argument (see Holes).

Atom completion

If point is at a non-callable position, completion-at-point suggests matching atoms and functors as completion candidates.