Next: Statement Templates, Previous: Formatting Parameter Lists, Up: Top [Contents][Index]
Casing of identifiers, attributes and keywords is automatically
performed while typing when the variable ada-auto-case
is set.
Every time you press a word separator, the previous word is
automatically cased.
You can customize the automatic casing differently for keywords,
attributes and identifiers. The relevant variables are the following:
ada-case-keyword
, ada-case-attribute
and
ada-case-identifier
.
All these variables can have one of the following values:
downcase-word
The word will be lowercase. For instance My_vARIable
is
converted to my_variable
.
upcase-word
The word will be uppercase. For instance My_vARIable
is
converted to MY_VARIABLE
.
ada-capitalize-word
The first letter and each letter following an underscore (‘_’)
are uppercase, others are lowercase. For instance My_vARIable
is converted to My_Variable
.
ada-loose-case-word
Characters after an underscore ‘_’ character are uppercase,
others are not modified. For instance My_vARIable
is converted
to My_VARIable
.
Ada mode allows you to define exceptions to these rules, in a file
specified by the variable ada-case-exception-file
(default ~/.emacs_case_exceptions). Each line in this file
specifies the casing of one word or word fragment. Comments may be
included, separated from the word by a space.
If the word starts with an asterisk (*), it defines the casing as a word fragment (or “substring”); part of a word between two underscores or word boundary.
For example:
DOD Department of Defense *IO GNAT The GNAT compiler from Ada Core Technologies
The word fragment *IO
applies to any word containing “_io”;
Text_IO
, Hardware_IO
, etc.
There are two ways to add new items to this file: you can simply edit
it as you would edit any text file. Or you can position point on the
word you want to add, and select menu ‘Ada | Edit | Create Case
Exception’, or press C-c C-y (ada-create-case-exception
).
The word will automatically be added to the current list of exceptions
and to the file.
To define a word fragment case exception, select the word fragment, then select menu ‘Ada | Edit | Create Case Exception Substring’.
It is sometimes useful to have multiple exception files around (for
instance, one could be the standard Ada acronyms, the second some
company specific exceptions, and the last one some project specific
exceptions). If you set up the variable ada-case-exception-file
as a list of files, each of them will be parsed and used in your emacs
session. However, when you save a new exception through the menu, as
described above, the new exception will be added to the first file in
the list.
Adjust case in the whole buffer (ada-adjust-case-buffer
).
Create a new entry in the exception dictionary, with the word under
the cursor (ada-create-case-exception
)
Rereads the exception dictionary from the file
ada-case-exception-file
(ada-case-read-exceptions
).
Next: Statement Templates, Previous: Formatting Parameter Lists, Up: Top [Contents][Index]