Node:Identifier completion



Identifier completion

Overview

Emacs and the Ada mode provide two general ways for the completion of identifiers. This is an easy way to type faster: you just have to type the first few letters of an identifiers, and then loop through all the possible completions.

The first method is general for Emacs. It will work both with Ada buffers, but also in C buffers, Java buffers, ... The idea is to parse all the opened buffers for possible completions.

For instance, if the following words are present in any of the opened files: my_identifier, my_subprogam, then you will have this scenario:

You type:  my<M-/>
Emacs will display:  my_identifier
If you press <M-/> once again, Emacs will replace my_identifier with
my_subprogram.
Pressing <M-/> once more will bring you back to my_identifier.

This is a very fast way to do completion, and the casing of words will also be respected.

The second method is specific to Ada buffer, and even to users of the Gnat compiler. Emacs will search the cross-information found in the .ali files generated by Gnat for possible completions.

The main advantage is that this completion is more accurate: only existing identifier will be suggested, you don't need to have a file opened that already contains this identifiers,...

On the other hand, this completion is a little bit slower and requires that you have compiled your file at least once since you created that identifier.

Summary of commands

C-TAB ada-complete-identifier
complete accurately current identifier using information in .ali file
M-/
complete identifier using buffer information (not ada specific)