On a text-only terminal, the Emacs display occupies the whole screen. On the X Window System, Emacs creates its own X windows to use. We use the term frame to mean an entire text-only screen or an entire X window used by Emacs. Emacs uses both kinds of frames in the same way to display your editing. Emacs normally starts out with just one frame, but you can create additional frames if you wish. See section Frames and X Windows.
When you start Emacs, the entire frame except for the last line is devoted to the text you are editing. This area is called window. The last line is a special echo area or minibuffer window where prompts appear and where you can enter responses. You can subdivide the large text window horizontally or vertically into multiple text windows, each of which can be used for a different file (see section Multiple Windows). In this manual, the word ``window'' always refers to the subdivisions of a frame within Emacs.
The window that the cursor is in is the selected window, in which editing takes place. Most Emacs commands implicitly apply to the text in the selected window (though mouse commands generally operate on whatever window you click them in, whether selected or not). The other windows display text for reference only, unless/until you select them. If you use multiple frames under the X Window System, then giving the input focus to a particular frame selects a window in that frame.
Each window's last line is a mode line which describes what is going on in that window. It appears in inverse video if the terminal supports that, and contains text that starts like -----Emacs: something. Its purpose is to indicate what buffer is being displayed above it in the window; what major and minor modes are in use; and whether the buffer contains unsaved changes.
Within Emacs, the terminal's cursor shows the location at which editing commands will take effect. This location is called point. Many Emacs commands move point through the text, so that you can edit at different places in it. You can also place point by clicking mouse button 1.
While the cursor appears to point at a character, you should think of point as between two characters; it points before the character that appears under the cursor. For example, if your text looks like frob with the cursor over the b, then point is between the o and the b. If you insert the character ! at that position, the result is fro!b, with point between the ! and the b. Thus, the cursor remains over the b, as before.
Terminals have only one cursor, and when output is in progress it must appear where the typing is being done. This does not mean that point is moving. It is only that Emacs has no way to show you the location of point except when the terminal is idle.
If you are editing several files in Emacs, each in its own buffer, each buffer has its own point location. A buffer that is not currently displayed remembers where point is in case you display it again later.
When there are multiple windows in a frame, each window has its own point location. The cursor shows the location of point in the selected window. This also is how you can tell which window is selected. If the same buffer appears in more than one window, each window has its own position for point in that buffer.
When there are multiple frames, each frame can display one cursor. The cursor in the selected frame is solid; the cursor in other frames is a hollow box, and appears in the window that would be selected if you give the input focus to that frame.
Single-character commands do not echo in Emacs, and multi-character commands echo only if you pause while typing them. As soon as you pause for more than a second in the middle of a command, Emacs echoes all the characters of the command so far. This is to prompt you for the rest of the command. Once echoing has started, the rest of the command echoes immediately as you type it. This behavior is designed to give confident users fast response, while giving hesitant users maximum feedback. You can change this behavior by setting a variable (see section Variables Controlling Display).
If a command cannot be executed, it may print an error message in the echo area. Error messages are accompanied by a beep or by flashing the screen. Also, any input you have typed ahead is thrown away when an error happens.
Some commands print informative messages in the echo area. These messages look much like error messages, but they are not announced with a beep and do not throw away input. Sometimes the message tells you what the command has done, when this is not obvious from looking at the text being edited. Sometimes the sole purpose of a command is to print a message giving you specific information---for example, C-x = prints a message describing the character position of point in the text and its current column in the window. Commands that take a long time often display messages ending in ... while they are working, and add done at the end when they are finished.
Echo area informative messages appear also in a buffer named *Messages*. If you miss a message that appears briefly on the screen, you can switch to the *Messages* buffer to see it again. Garbage collection messages are omitted from *Messages*, and successive progress messages are often collapsed into one.
The size of *Messages* is limited to a certain number of lines. The variable
The echo area is also used to display the minibuffer, a window that is used for reading arguments to commands, such as the name of a file to be edited. When the minibuffer is in use, the echo area begins with a prompt string that usually ends with a colon; also, the cursor appears in that line because it is the selected window. You can always get out of the minibuffer by typing C-g. See section The Minibuffer.
Each text window's last line is a mode line which describes what is going on in that window. When there is only one text window, the mode line appears right above the echo area. The mode line is in inverse video if the terminal supports that, it starts and ends with dashes, and it contains text like Emacs: something.
A few special editing modes, such as Dired and Rmail, display something else in place of Emacs: something. The rest of the mode line still has the usual meaning.
Normally, the mode line looks like this:
--ch-Emacs: buf (major minor)----pos------
This gives information about the buffer being displayed in the window: the buffer's name, what major and minor modes are in use, whether the buffer's text has been changed, and how far down the buffer you are currently looking.
ch contains two stars ** if the text in the buffer has been edited (the buffer is ``modified''), or -- if the buffer has not been edited. For a read-only buffer, it is %* if the buffer is modified, and %% otherwise.
The buffer displayed in the selected window (the window that the cursor is in) is also Emacs's selected buffer, the one that editing takes place in. When we speak of what some command does to ``the buffer'', we are talking about the currently selected buffer.
pos tells you whether there is additional text above the top of the window, or below the bottom. If your buffer is small and it is all visible in the window, pos is All. Otherwise, it is Top if you are looking at the beginning of the buffer, Bot if you are looking at the end of the buffer, or nn%, where nn is the percentage of the buffer above the top of the window.
major is the name of the major mode in effect in the buffer. At any time, each buffer is in one and only one of the possible major modes. The major modes available include Fundamental mode (the least specialized), Text mode, Lisp mode, C mode, Texinfo mode, and many others. See section Major Modes, for details of how the modes differ and how to select one.
Some major modes display additional information after the major mode name. For example, Rmail buffers display the current message number and the total number of messages. Compilation buffers and Shell buffers display the status of the subprocess.
minor is a list of some of the minor modes that are turned on at the moment in the window's chosen buffer. For example, Fill means that Auto Fill mode is on. Abbrev means that Word Abbrev mode is on. Ovwrt means that Overwrite mode is on. See section Minor Modes, for more information. Narrow means that the buffer being displayed has editing restricted to only a portion of its text. This is not really a minor mode, but is like one. See section Narrowing. Def means that a keyboard macro is being defined. See section Keyboard Macros.
In addition, if Emacs is currently inside a recursive editing level, square brackets ([...]) appear around the parentheses that surround the modes. If Emacs is in one recursive editing level within another, double square brackets appear, and so on. Since recursive editing levels affect Emacs globally, not just one buffer, the square brackets appear in every window's mode line or not in any of them. See section Recursive Editing Levels.
See section Optional Mode Line Features, for features that add other handy information to the mode line, such as the current line number of point, the current time, and whether new mail for you has arrived.
ASCII consists of 128 character codes. Some of these codes are assigned graphic symbols such as a and =; the rest are control characters, such as Control-a (usually written C-a for short). C-a gets its name from the fact that you type it by holding down the CTRL key while pressing a.
Some control characters have special names, and special keys you can type them with: for example, RET, TAB, LFD, DEL and ESC. The space character is usually referred to below as SPC, even though strictly speaking it is a graphic character whose graphic happens to be blank.
On ASCII terminals, there are only 32 possible control characters. These are the control variants of letters and @\^_. In addition, the shift key is meaningless with control characters: C-a and C-A are the same character, and Emacs cannot distinguish them.
But the Emacs character set has room for control variants of all characters, and for distinguishing between C-a and C-A. X Windows makes it possible to enter all these characters. For example, C-- (that's Control-Minus) and C-5 are meaningful Emacs commands under X.
Another Emacs character set extension is that characters have additional modifier bits. Only one modifier bit is commonly used; it is called Meta. Every character has a Meta variant; examples include Meta-a (normally written M-a, for short), M-A (not the same character as M-a, but those two characters normally have the same meaning in Emacs), M-RET, and M-C-a. For reasons of tradition, we usually write C-M-a rather than M-C-a; logically speaking, the order in which the modifier keys CTRL and META are mentioned does not matter.
Some terminals have a META key, and allow you to type Meta characters by holding this key down. Thus, Meta-a is typed by holding down META and pressing a. The META key works much like the SHIFT key. Such a key is not always labeled META, however, as this function is often a special option for a key with some other primary purpose.
If there is no META key, you can still type Meta characters using two-character sequences starting with ESC. Thus, to enter M-a, you could type ESC a. To enter C-M-a, you would type ESC C-a. ESC is allowed on terminals with META keys, too, in case you have formed a habit of using it. X Windows provides several other modifier keys that can be applied to any input character. These are called SUPER, HYPER and ALT. We write s-, H- and A- to say that a character uses these modifiers. Thus, s-H-C-x is short for Super-Hyper-Control-x. Not all X terminals actually provide keys for these modifier flags---in fact, many terminals have a key labeled ALT which is really a META key. The standard key bindings of Emacs do not include any characters with these modifiers. But you can assign them meanings of your own by customizing Emacs.
Keyboard input includes keyboard keys that are not characters at all: for example function keys and arrow keys. Mouse buttons are also outside the gamut of characters. You can modify these events with the modifier keys CONTROL, META, SUPER, HYPER and ALT like keyboard characters.
Input characters and non-character inputs are collectively called input events. See section 'Input Events' in The Emacs Lisp Manual, for more information. If you are not doing Lisp programming, but simply want to redefine the meaning of some characters or non-character events, see section Customization.
ASCII terminals cannot really send anything to the computer except ASCII characters. These terminals use a sequence of characters to represent each function key. But that is invisible to the Emacs user, because the keyboard input routines recognize these special sequences and convert them to function key events before any other part of Emacs gets to see them.
A key sequence (key, for short) is a sequence of input events that are meaningful as a unit---as ``a single command.'' Some Emacs command sequences are just one character or one event; for example, just C-f is enough to move forward one character. But Emacs also has commands that take two or more events to invoke.
If a sequence of events is enough to invoke a command, it is a complete key. Examples of complete keys include C-a, X, RET, NEXT (a function key), DOWN (an arrow key), C-x C-f and C-x 4 C-f. If it isn't long enough to be complete, we call it a prefix key. The above examples show that C-x and C-x 4 are prefix keys. Every key sequence is either a complete key or a prefix key.
Most single characters constitute complete keys in the standard Emacs command bindings. A few of them are prefix keys. A prefix key combines with the following input event to make a longer key sequence, which may itself be complete or a prefix. For example, C-x is a prefix key, so C-x and the next input event combine to make a two-character key sequence. Most of these key sequences are complete keys, including C-x C-f and C-x b. A few, such as C-x 4 and C-x r, are themselves prefix keys that lead to three-character key sequences. There's no limit to the length of a key sequence, but in practice people rarely use sequences longer than four events.
By contrast, you can't add more events onto a complete key. For example, the two-character sequence C-f C-k is not a key, because the C-f is a complete key in itself. It's impossible to give C-f C-k an independent meaning as a command. C-f C-k is two key sequences, not one.
All told, the prefix keys in Emacs are C-c, C-h, C-x, C-x C-a, C-x n, C-x r, C-x v, C-x 4, C-x 5, C-x 6, and ESC. But this is not cast in concrete; it is just a matter of Emacs's standard key bindings. If you customize Emacs, you can make new prefix keys, or eliminate these. See section Customizing Key Bindings.
If you do make or eliminate prefix keys, that changes the set of possible key sequences. For example, if you redefine C-f as a prefix, C-f C-k automatically becomes a key (complete, unless you define it too as a prefix). Conversely, if you remove the prefix definition of C-x 4, then C-x 4 f (or C-x 4 anything) is no longer a key.
Typing the help character (C-h or F1) after a prefix character displays a list of the commands starting with that prefix. There are a few prefix characters for which C-h does not work---for historical reasons, they have other meanings for C-h which are not easy to change. But F1 should work for all prefix characters.
This manual is full of passages that tell you what particular keys do. But Emacs does not assign meanings to keys directly. Instead, Emacs assigns meanings to named commands, and then gives keys their meanings by binding them to commands.
Every command has a name chosen by a programmer. The
name is usually made of a few English words separated by dashes; for example,
The bindings between keys and commands are recorded in various tables called keymaps. See section Keymaps.
When we say that ``C-n moves down vertically one line'' we are glossing over
a distinction that is irrelevant in ordinary use but is vital in understanding how to
customize Emacs. It is the command
In the rest of this manual, we usually ignore this subtlety to keep things simple. To
give the information needed for customization, we state
the name of the command which really does the work in
parentheses after mentioning the key that runs it. For example, we will say that ``The command C-n (
While we are on the subject of information for customization
only, it's a good time to tell you about variables. Often the description of a command will say, ``To change this, set the variable
Emacs buffers use an 8-bit character set, because bytes have 8 bits. ASCII graphic characters in Emacs buffers are displayed with their graphics. The newline character (which has the same character code as LFD) is displayed by starting a new line. The tab character is displayed by moving to the next tab stop column (normally every 8 columns). Other control characters are displayed as a caret (^) followed by the non-control version of the character; thus, C-a is displayed as ^A. Non-ASCII characters 128 and up are displayed with octal escape sequences; thus, character code 243 (octal) is displayed as \243.
You can customize the display of these character codes (or ASCII characters) by creating a display table. See section 'Display Tables' in The Emacs Lisp Reference Manual. This is useful for editing files that use 8-bit European character sets. See section European Character Set Display.
Email addresses listed on this site may NOT be used for unsolicited commercial email.
Portions (c)Copyright, 1996-2005 by