Next: , Previous: , Up: Autotyping   [Contents][Index]

1 Using Skeletons

When you want Emacs to insert a form letter or a typical construct of the programming language you are using, skeletons are a means of accomplishing this. Normally skeletons each have a command of their own, that, when called, will insert the skeleton. These commands can be issued in the usual ways (see Commands in The GNU Emacs Manual). Modes that offer various skeletons will often bind these to key-sequences on the C-c prefix, as well as having an Insert menu and maybe even predefined abbrevs for them (see Skeletons as Abbrev Expansions).

The simplest kind of skeleton will simply insert some text indented according to the major mode and leave the cursor at a likely place in the middle. Interactive skeletons may prompt you for a string that will be part of the inserted text.

Skeletons may ask for input several times. They even have a looping mechanism in which you will be asked for input as long as you are willing to furnish it. An example would be multiple “else if” conditions. You can recognize this situation by a prompt ending in RET, C-g or C-h. This means that entering an empty string will simply assume that you are finished. Typing quit on the other hand terminates the loop but also the rest of the skeleton, e.g., an “else” clause is skipped. Only a syntactically necessary termination still gets inserted.