2.4.1 Smart Completion

The Semantic Analyzer can be used to perform code completion in a manner that takes the local context into account. (In addition to the user commands in this section, Semantic Idle Completions mode also uses the Semantic Analyzer. See Idle Completions Mode.)

Command: semantic-analyze-possible-completions context

This is the most basic command for Semantic Analyzer-based completion. Called interactively, it displays a list of the possible completions for the symbol at point.

When called from a Lisp program, semantic-analyze-possible-completions does not display a completions list. The argument context should be either a buffer position, or a context object. The return value is a list of Semantic tag objects that complete the symbol for context, based on the following criteria:

  • Elements currently in scope.
  • Constants currently in scope.
  • Elements matching the context’s :prefix.
  • Type of the completion matching the type of the context.

Most of the other commands documented in this section call semantic-analyze-possible-completions internally.

Command: semantic-complete-analyze-inline

This command is bound to C-c , SPC when Semantic mode is enabled (see Semantic mode user commands). It displays a list of possible completions for the symbol at point, and activates a special set of key bindings for choosing a completion.

You can type RET to accept the current completion, M-n and M-p to cycle through the possible completions, TAB to complete as far as possible and then cycle through completions, and either C-g or any other key to abort the completion.

This command is similar to the completion performed by Semantic Idle Completions mode. The main difference is that it is called explicitly, whereas Semantic Idle Completions mode completes during idle time (see Idle Completions Mode).

Option: semantic-complete-inline-analyzer-idle-displayer-class

The value of this variable determines how semantic-complete-analyze-inline shows its completions. Possible values include:


Display completions in a separate window. This is the default value.


Display completions “inline” with the buffer text, similar to the default behavior of Semantic Idle Completions mode (see Idle Completions Mode).


Display completions in a tooltip.

In addition to semantic-complete-analyze-inline, you can use the simpler command semantic-ia-complete-symbol point. This behaves like the usual M-TAB (complete-symbol) command (see Symbol Completion in Emacs manual), except it uses the Semantic Analyzer.

Command: semantic-ia-complete-symbol point

Complete the current symbol at point.