# global-abbrev-file(2)

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

## NAME

global-abbrev-file, buffer-abbrev-file - Set abbreviation file(s).

## SYNOPSIS

n global-abbrev-file "abbrev-file"
n buffer-abbrev-file "abbrev-file"

## DESCRIPTION

The abbreviation files allow the user to define a set of short-cut expansion text, whereby a short sequence of chararacters are associated with a longer text segment. When the short sequence is entered, the user may elect to maually expand the sequnce with the associated replacement text. Provision for cursor positioning may be made in the replacement text.

buffer-abbrev-file sets the current buffer's abbreviation file (limit of one abbreviation file per buffer). buffer-abbrev-file does the minimal amount of work to increase speed at load-up. The first use of expand-abbrev(2) attempts to load the abbreviation file at which point errors may be reported.

An argument n of zero, forces the buffer abbreviation file to be uncached, such that the next abbreviation that is expanded forces a re-load of the abbreviation file. This is typically only used when an abbreviation file is being constructed and tested.

global-abbrev-file assigns a global set of abbreviations accross ALL buffers, such that the abbreviation is available regardless of the current buffer type. The global abbreviation file has a lower presidence than the buffer-abbrev-file, hence the currently assigned buffer-abbrev-file is searched before the global-abbrev-file.

Similarly for global-abbrev-file, an argument of zero forces the global abbreviation file to be uncached and re-loaded on the next use.

An abbreviation is a string which is expanded to an alternate form, e.g.

e.g. -> for example

or

PI -> 3.1415926536

etc.

An abbreviation file is an ordinary text file with a strict format, it is loaded only once at the first call to expand-abbrev(2), from then on it reminds buffered. An abbreviation file has an abbreviation per line, they cannot use multiple lines. This is not a draw back as the expansion string is executed using execute-string(2) so any MicroEmacs 2009 command may also be called.

For example the following expansion string inserts the string "`!continue`" and a newline:-

"`!abort\r`"

Note that '`\r`' is used instead of '`\n`' as C-m is bound to newline(2) and not C-j. The expansion string can also make use of a few useful abbreviations:-

\p

Mark the current position (expanded to "`C-x C-a P`")

\P

Move cursor to the marked position (expanded to "`C-x a P`")

See help on execute-string(2) for more useful abbreviations.

## EXAMPLE

The abbreviation must be on the left hand side followed by at least 1 space, the expansion string must then be on the same line in quotes. So for the given examples, the abbreviation file would be:

    |
    |e.g. "for example"
    |PI   "3.1415926536"
    |

The following abbreviation could be used for a C if-else statement.

    |
    |if "if(\p)\r{\r\r}\relse\r{\r\r}\r\P"
    |

This is particularly useful for email address, e.g.

    |
    |JA "\"JASSPA\" <support@jasspa.com>"
    |

The following example is MicroEmacs 2009 C-Mode abbreviation file for constructing C files. Remember \p is where the cursor is positioned following the expansion.

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

## NOTES

Abbreviation files are given the extension .eaf in the MicroEmacs 2009 home directory.

One of the easiest ways to create more complex abbreviations is to record a keyboard macro, name it and then insert the resultant macro. See notes on commands start-kbd-macro(2), name-kbd-macro(2) and insert-macro(2).

Try to avoid using named key, such as "`up`" and "`return`", as the keyboard macro equivalent is not readable and is likely to change in future releases.

## FILES

c.eaf - C-Mode abbreviation file. emf.eaf - Macro code abbreviation file.

## SEE ALSO

execute-string(2), expand-abbrev(2), insert-macro(2), iso-accents-mode(3), name-kbd-macro(2), start-kbd-macro(2), eaf(8).

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

</HMTL>