GNU Info

Info Node: (ada-mode)Automatic Casing

(ada-mode)Automatic Casing


Next: Statement Templates Prev: Formatting Parameter Lists Up: Top
Enter node , (file) or (file)node

Automatic Casing
****************

   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  previous word  will simply  be in  all lower  cases.   For
     instance `My_vARIable' is converted to `my_variable'.

`upcase-word'
     The previous word will be  fully converted to upper cases.  For
     instance `My_vARIable' is converted to `MY_VARIABLE'.

`ada-capitalize-word'
     All letters, except the first one of the word and every letter
     after the `_'  character are  lower cased.  Other  letters are
     upper cased.   For instance `My_vARIable' is converted to
     `My_Variable'.

`ada-loose-case-word'
     No letters is  modified in the previous word, except  the ones
     after the `_' character that are  upper cased.  For instance
     `My_vARIable' is converted to `My_VARIable'.

   These  functions, although they  will work  in most  cases, will
not be accurate sometimes. The  Ada mode allows you to  define some
exceptions, that will always be cased the same way.

   The idea  is to  create a dictionary  of exceptions,  and store it
in a file. This file should contain  one identifier per line, with the
casing you   want   to   force.   The   default   name   for   this
file   is `~/.emacs_case_exceptions'.  You can  of course  change  this
name, through the variable `ada-case-exception-file'.

   Note that  each line  in this file  must start  with the key  word
whose casing  you want  to  specify. The  rest of  the  line can  be
used  for comments  (explaining  for  instance  what  an  abbreviation
means,  as recommended in the Ada 95  Quality and Style, paragraph
3.1.4).  Thus, a good example for this file could be:

     DOD        Department of Defense
     Text_IO
     GNAT       The GNAT compiler from Ada Core Technologies

   When  working on  project involving  multiple programmers,  we
recommend that every  member of  the team  sets this variable  to the
same value, which  should  point  to  a  system-wide  file that  each
of  them  can write.  That  way,  you  will  ensure  that  the  casing
is  consistent throughout your application(s).

   There are two ways to add new items to this file: you can simply
edit it as you  would edit any  text file, and  add or suppress entries
in this file.  Remember that  you should  put one  entity per  line.
The other, easier way, is to position the cursor  over the word you
want to add, in an Ada buffer.  This word should have the casing  you
want.  Then simply select  the  menu `Ada->Edit->Create  Case
Exception',  or the  key `C-c C-y' (`ada-create-case-exception'). The
word will automatically be added to the current list of exceptions and
to the file.

   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 only.  You  can not automatically add  an exception to one
of the other files, although you can of course edit the files by hand
at any time.

   Automatic casing can be performed on port or whole buffer using:

`C-c C-b'
     Adjust case in the whole buffer (`ada-adjust-case-buffer').

`C-c C-y'
     Create a new entry in the exception dictionary, with the word under
     the cursor (`ada-create-case-exception')

`C-c C-t'
     Rereads the exception dictionary from the file
     `ada-case-exception-file' (`ada-case-read-exceptions').


automatically generated by info2www version 1.2.2.9