6.1.9. Smart Space Key

The Smart Space Key will expand abbreviations for Ada reserved words and will, for those constructs that take a name or a label on the “end”, also expand those abbreviations into partially-complete constructs with the corresponding name or label included.

Expansions follow the user’s letter casing preferences for reserved words and identifiers.

The Smart Space Key is disabled by default and is controlled by preferences on the Editor preference page.

If the action is enabled, the additional relevant preference is the length of words considered as candidate abbreviations to be expanded. The default length is three characters, meaning that only words three characters or longer will be considered. Thus the facility is minimally intrusive and, moreover, the degree of intrusion is under your control.

If the preference is disabled, pressing the space key will insert one space, as usual.

6.1.9.1. Reserved Word Expansion

If an abbreviation of a reserved word is either on a line by itself or follows only a label, that abbreviation is expanded into the full spelling. Note that not all reserved words are candidates for expansion: they must be long enough for expansion to be of use in the first place.

For example, in the following figure the word “proc” has been entered and the space key is about to be pressed:

smart space key keyword before expansion

After the space key is pressed the abbreviation has been expanded to the full reserved word (and a trailing space has been inserted):

smart space key keyword after expansion

A reserved word that is fully spelled does not require expansion itself, but, for the sake of minimal intrusion, also does not invoke the construct expansion described below. Thus a user who types everything will not be intruded upon except for the case in which a user-defined identifier matches an abbreviation for a reserved word. To mitigate this effect the minimum abbreviation length may be set to a larger value by altering the preference.

Note that “for” is treated specially. It is a complete reserved word but is nonetheless expanded. Also, “for” is the start of an attribute definition clause so it will not expand unless it appears in a sequence of statements.

6.1.9.2. Begin-End Pair Expansion

Begin-end pairs for program units are expanded to include the corresponding unit name. Nested declarations are ignored such that the correct name is used in the expansion.

For example, in the following figure the abbreviation “beg” has been entered on line 20 and the space key is about to be pressed:

smart space key before word begin expansion

After the space key is pressed the abbreviation for “begin” has been expanded to the full begin-end par with the name of the procedure included. The cursor is placed inside the sequence of statements at the initial indentation level, to a depth specified by the indentation preference:

smart space key after word begin expansion

6.1.9.3. Named Statement Expansion

Constructs that require a trailing name are expanded to include that name. These include named block statements, named basic loops, named while-loops, and named for-loops.

For example, a named loop is required to have the loop name follow the “end loop”. In the following figure the name and loop abbreviation have been entered and the space key is about to be pressed:

smart space key before named loop expansion

After the space key is pressed the loop has been expanded with the name of the loop included. The cursor is placed inside the sequence of statements at the initial indentation level, to a depth specified by the indentation preference:

smart space key after named loop expansion

Note also that the user-specified letter casing has been applied to the name (in this example the “Smart_CASED” policy was in force) and the reserved words are similarly formatted (with the “lowercase” policy in this instance).

Continuing the example, we can now insert a named declare block. In the following figure the name and abbreviation have been entered and the space key is about to be pressed:

smart space key before named declare block expansion

After the space key is pressed the declare block has been expanded with the name of the block included. Since this is a block statement with a declarative part, the editor expects that declarations are intended and places the cursor in the declarative region:

smart space key after named declare block expansion

6.1.9.4. Unnamed Statement Expansion

The named constructs above do not require names, they just require the name to be repeated if a name is given in the first place. For completeness these constructs will also expand when no name is applied.

For example, in the following figure the word “for” has been entered on line 21 and the space key is about to be pressed:

smart space key before unnamed loop expansion

After the space key is pressed the loop has been expanded and the cursor is placed so that the loop parameter specification can be entered:

smart space key after unnamed loop expansion

After entering the loop parameter specification you press the End key to go to the end of the line and then press the Enter key to open a new line within the loop:

smart space key about to enter body of loop