# eaf(8)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

eaf - MicroEmacs abbreviation file format

## SYNOPSIS

<pattern> <insertionString>
<pattern> <insertionString>
<pattern> <insertionString>
<pattern> <insertionString>

## DESCRIPTION

The MicroEmacs 2009 abbreviation file, typically given the extension .eaf, defines a set of shorthand expansion strings which are used by the command expand-abbrev(2). buffer-abbrev-file(2) defines the abbreviation file.

The abbreviation file line based, with one abbreviation per line, with no intervening blank lines. Each line comprises of two columns, the first column <pattern> identifies the source pattern to be expanded, the second column <insertionString> defines the replacement text. The two text columns are separated by a space character.

When expand-abbrev(2) is invoked and the expansion <pattern> is recognized, then <pattern> is deleted from the buffer and replaced with <insertionString>.

The fields are defined as follows:-

<pattern>

The source pattern to be expanded. The data commences in text column 0 and spans to the first white space character (`SPACE` or `tab`). The pattern may not include any white space characters.

<insertionString>

The replacement string exists from the first non-white space character following the <pattern> to the end of the line. The replacement string may include special tokens, delimited by a backslash ('`\`') character which are interpreted as follows:-

\b Move cursor backwards

A positioning control. Allows the cursor to be moved backwards 1 character.

\d Delete `tab` backwards

Back tab. Deletes a tab character backwards.

\m"<string>" Macro execution

Takes the remainder of the line as a keyboard macro definition. The macro string is generated using insert-macro(2) and must be contained in double quotes. When invoked the keyboard macro is executed and the appropriate text is inserted into a buffer. This is typically only used for more complex operations.

\p Position

The resultant position of the cursor following the expansion. If the cursor position is not specified, the cursor is placed at the end of the expansion string by default.

\r Carriage Return (Newline)

A newline in the replacement text. Note while indent(2m) is enabled a sequence a single "\r" retains the indent on the next line, however a sequence of two "\r\r" characters does not retain the tab position and returns the cursor to the start of the second line. If blank lines are required retaining tab positioning then a keyboard macro string should be used instead. (see "\m" above).

\t Tab

A `tab` character in the replacement text.

## EXAMPLE

The following example provides abbreviations for the 'C' programming language, found in file c.eaf. All cursor positions in the examples are shown by <@>.

    #i #include <\p>\r
    #d #define \p
    if if(\p)\r{\r\r}\r
    ef else if(\p)\r{\r\r}\r
    el else\r{\r\p\r}\r
    wh while(\p)\r{\r\r}\r
    sw switch(\p)\r{\rcase :\rdefault :\r}\r

Given that the abbreviation file has been declared then expansion of:

    #d<@>       =>      #define <@>

    if<@>       =>      if(<@>)
                        {

                        }

    sw<@>       =>      switch(<@>)
                        {
                        case :
                        default :
                        }

Note, in all of the examples, the abbreviation replacement strings specify a resultant cursor position, typically where the next edit will take place.

The macros may alternatively be defined using keyboard macros. The aforementioned macros could have been re-written with the following definitions which are equivalent:-

    #i \m"#include <\CX\CAP>\CM\CXaP\CX)"
    #d \m"#define \CX)"
    if \m"if(\CX\CAP)\CM{\CM}\CXaP\CX)"
    ef \m"else if(\CX\CAP)\CM{\CM\CM}\CM\CXaP\CX)"
    el \m"else\CM{\CM\CX\CAP\CM}\CM\CXaP\CX)"
    wh \m"while(\CX\CAP)\CM{\CM\CM}\CM\CXaP\CX)"
    sw \m"switch(\CX\CAP)\CM{\CMcase :\CMdefault:\CM}\CM\CXaP\CX)"

Within a macro, the cursor positioning is generally achieved by setting a mark where the resultant cursor is to be positioned (see set-mark(2)), when the macro is finished then an exchange-point-and-mark(2) is initiated to move the cursor to the correct position; alternatively a sequence of cursor movements may be used.

The "\b" and "\d" are typically used for positioning the cursor on subsequent lines. "\d" is the inverse of "\t". Consider the following Pascal definition for an else, begin and end sequence:-

    el else\rbegin\r\t\p;\r\dend;

with indent(2m) mode enabled generates:-

            else
            begin
                <@>;
            end;

Similarly the "\b" is typically used when indent(2m) is enabled, but when the tab spacing is known. Consider the following example used in the MicroEmacs 2009 .emf files to define a help entry. In this case the indent is known to be 5 characters. Hence to move the cursor back 5 characters then a sequence of \b's are used:-

    !h def .. \rSEE ALSO\r     <cross references>\r\b\b\b\b\b!ehelp

the expansion in this case is:-

    define-help "<@>"

    ...

    SEE ALSO
         <cross references>
    !ehelp

## FILES

The default abbreviation files are located in the MicroEmacs 2009 home directory.

User's may specify their own abbreviation files by shadowing the home directory file with their own file located in a personal MicroEmacs 2009 directory. See $user-path(5).

## SEE ALSO

expand-abbrev(2), buffer-abbrev-file(2), global-abbrev-file(2), iso-accents-mode(3), $user-path(5).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>