6.8 Word Abbreviation

  • 6.8.1 Basic Commands
  • 6.8.2 Word Abbrev Files
  • 6.8.3 Listing Word Abbrevs
  • 6.8.4 Editing Word Abbrevs
  • 6.8.5 Deleting Word Abbrevs
  • Word abbreviation provides a way to speed the typing of frequently used words and phrases. When in Abbrev mode, typing a word delimiter causes the previous word to be replaced with its expansion if there is one currently defined. The expansion for an abbrev may be any string, so this mode can be used for abbreviating programming language constructs and other more obscure uses. For example, Abbrev mode can be used to automatically correct common spelling mistakes and to enforce consistent capitalization of identifiers in programs. [annotate]

    Abbrev is an abbreviation for abbreviation, which is used for historical reasons. Obviously the original writer of Abbrev mode hated to type long words and could hardly use Abbrev mode while writing Abbrev mode. [annotate]

    A word abbrev can be either global or local to a major mode. A global word abbrev is defined no matter what the current major mode is, while a mode word abbrev is only defined when its mode is the major mode in the current buffer. Mode word abbrevs can be used to prevent abbrev expansion in inappropriate contexts. [annotate]

    6.8.1 Basic Commands

    Abbrev Mode   [Command]
              

    This command turns on Abbrev mode in the current buffer. If Abbrev mode is already on, it is turned off. Abbrev mode must be on for the automatic expansion of word abbrevs to occur, but the abbreviation commands are bound globally and may be used at any time. [annotate]

    [annotate]

    Abbrev Expand Only   [Command]
              

    This is the word abbrev expansion command. If the word before the point is a defined word abbrev, then it is replaced with its expansion. The replacement is done using the same case-preserving heuristic as is used by Query Replace. This command is globally bound to M-Space so that abbrevs can be expanded when Abbrev mode is off. An undesirable expansion may be inhibited by using C-q to insert the delimiter. [annotate]

    [annotate]

    Inverse Add Global Word Abbrev  (bound to C-x -) [Command]
    Inverse Add Mode Word Abbrev  (bound to C-x C-h, C-x Backspace) [Command]
              

    Inverse Add Global Word Abbrev prompts for a string and makes it the global word abbrev expansion for the word before the point. [annotate]

    Inverse Add Mode Word Abbrev is identical to Inverse Add Global Word Abbrev except that it defines an expansion which is local to the current major mode. [annotate]

    [annotate]

    Make Word Abbrev   [Command]
              

    This command defines an arbitrary word abbreviation. It prompts for the mode, abbreviation and expansion. If the mode "Global" is specified, then it makes a global abbrev. [annotate]

    [annotate]

    Add Global Word Abbrev  (bound to C-x +) [Command]
    Add Mode Word Abbrev  (bound to C-x C-a) [Command]
              

    Add Global Word Abbrev prompts for a word and defines it to be a global word abbreviation. The prefix argument determines which text is used as the expansion: [annotate]

    no prefix argument
    The word before the point is used as the expansion of the abbreviation. [annotate]
    zero prefix argument
    The text in the region is used as the expansion of the abbreviation. [annotate]
    positive prefix argument
    That many words before the point are made the expansion of the abbreviation. [annotate]
    negative prefix argument
    Do the same thing as Delete Global Word Abbrev instead of defining an abbreviation. [annotate]

    Add Mode Word Abbrev is identical to Add Global Word Abbrev except that it defines or deletes mode word abbrevs in the current major mode. [annotate]

    [annotate]

    Word Abbrev Prefix Mark  (bound to M-") [Command]
              

    This command allows Abbrev Expand Only to recognize abbreviations when they have prefixes attached. First type the prefix, then use this command. A hyphen (-) will be inserted in the buffer. Now type the abbreviation and the word delimiter. Abbrev Expand Only will expand the abbreviation and remove the hyphen. [annotate]

    Note that there is no need for a suffixing command, since Abbrev Expand Only may be used explicitly by typing M-Space. [annotate]

    [annotate]

    Unexpand Last Word  (bound to C-x u) [Command]
              

    This command undoes the last word abbrev expansion. If repeated, undoes its own effect. [annotate]

    [annotate]

    6.8.2 Word Abbrev Files

    A word abbrev file is a file which holds word abbrev definitions. Word abbrev files allow abbrevs to be saved so that they may be used across many editing sessions. [annotate]

    Abbrev Pathname Defaults  (initial value (pathname "abbrev.defns")) [Variable]
              

    This is sticky default for the following commands. When they prompt for a file to write, they offer this and set it for the next time one of them executes. [annotate]

    [annotate]

    Read Word Abbrev File   [Command]
              

    This command reads in a word abbrev file, adding all the definitions to those currently defined. If a definition in the file is different from the current one, the current definition is replaced. [annotate]

    [annotate]

    Write Word Abbrev File   [Command]
              

    This command prompts for a file and writes all currently defined word abbrevs out to it. [annotate]

    [annotate]

    Append to Word Abbrev File   [Command]
              

    This command prompts for a word abbrev file and appends any new definitions to it. An abbrev is new if it has been defined or redefined since the last use of this command. Definitions made by reading word abbrev files are not considered. [annotate]

    [annotate]

    6.8.3 Listing Word Abbrevs

    List Word Abbrevs   [Command]
    Word Abbrev Apropos   [Command]
              

    List Word Abbrevs displays a list of each defined word abbrev, with its mode and expansion. [annotate]

    Word Abbrev Apropos is similar, except that it only displays abbrevs which contain a specified string, either in the definition, expansion or mode. [annotate]

    [annotate]

    6.8.4 Editing Word Abbrevs

    Word abbrev definition lists are edited by editing the text representation of the definitions. Word abbrev files may be edited directly, like any other text file. The set of abbrevs currently defined in Hemlock may be edited using the commands described in this section. [annotate]

    The text representation of a word abbrev is fairly simple. Each definition begins at the beginning of a line. Each line has three fields which are separated by ASCII tab characters. The fields are the abbreviation, the mode of the abbreviation and the expansion. The mode is represented as the mode name inside of parentheses. If the abbrev is global, then the mode field is empty. The expansion is represented as a quoted string since it may contain any character. The string is quoted with double-quotes ("); double-quotes in the expansion are represented by doubled double-quotes. The expansion may contain newline characters, in which case the definition will take up more than one line. [annotate]

    Edit Word Abbrevs   [Command]
              

    This command inserts the current word abbrev definitions into the Edit Word Abbrevs buffer and then enters a recursive edit on the buffer. When the recursive edit is exited, the definitions in the buffer become the new current abbrev definitions. [annotate]

    [annotate]

    Insert Word Abbrevs   [Command]
              

    This command inserts at the point the text representation of the currently defined word abbrevs. [annotate]

    [annotate]

    Define Word Abbrevs   [Command]
              

    This command interprets the text of the current buffer as a word abbrev definition list, adding all the definitions to those currently defined. [annotate]

    [annotate]

    6.8.5 Deleting Word Abbrevs

    The user may delete word abbrevs either individually or collectively. Individual abbrev deletion neutralizes single abbrevs which have outlived their usefulness; collective deletion provides a clean slate from which to initiate abbrev definitions. [annotate]

    Delete All Word Abbrevs   [Command]
              

    This command deletes all word abbrevs which are currently defined. [annotate]

    [annotate]

    Delete Global Word Abbrev   [Command]
    Delete Mode Word Abbrev   [Command]
              

    Delete Global Word Abbrev prompts for a word abbreviation and deletes its global definition. If given a prefix argument, deletes all global abbrev definitions. [annotate]

    Delete Mode Word Abbrev is identical to Delete Global Word Abbrev except that it deletes definitions in the current major mode. [annotate]

    [annotate]