eaf - MicroEmacs abbreviation file format
<pattern> <insertionString>
<pattern> <insertionString>
<pattern> <insertionString>
<pattern> <insertionString>
The MicroEmacs '99 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>
<insertionString>
\b Move cursor backwards
\d Delete tab backwards
\m"<string>" Macro execution
\n Newline
\p Position
\t Tab
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>\n #d #define \p if if(\p)\n{\n\n}\n ef else if(\p)\n{\n\n}\n el else\n{\n\p\n}\n wh while(\p)\n{\n\n}\n sw switch(\p)\n{\ncase :\ndefault :\n}\n
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\nbegin\n\t\p;\n\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 '99 .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 .. \nSEE ALSO\n <cross references>\n\b\b\b\b\b!ehelp
the expansion in this case is:-
define-help "<@>" ... SEE ALSO <cross references> !ehelp
The default abbreviation files are located in the MicroEmacs '99 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 '99 directory. See $MEPATH(5).
(c) Copyright JASSPA 1999
Last Modified: 1999/07/05
Generated On: 1999/12/01