manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Kinds of User Input

GNU Emacs is designed for use with keyboard commands because that is the most efficient way to edit. You can do editing with the mouse, as in other editors, and you can give commands with the menu bar and tool bar, and scroll with the scroll bar. But if you keep on editing that way, you won't get the benefits of Emacs. Therefore, this manual documents primarily how to edit with the keyboard. You can force yourself to practice using the keyboard by using the shell command ‘emacs -nw’ to start Emacs, so that the mouse won't work.

Emacs uses an extension of the ASCII character set for keyboard input; it also accepts non-character input events including function keys and mouse button actions.

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 ASCII control characters have special names, and most terminals have special keys you can type them with: for example, <RET>, <TAB>, <DEL> and <ESC>. The space character is usually known as <SPC>, even though strictly speaking it is a graphic character that is blank.

Emacs extends the ASCII character set with thousands more printing characters (see section International Character Set Support), additional control characters, and a few more modifiers that can be combined with any character.

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.

The Emacs character set has room for control variants of all printing characters, and distinguishes C-A from C-a. Graphical terminals make it possible to enter all these characters. For example, C-- (that's Control-Minus) and C-5 are meaningful Emacs commands on a graphical terminal.

Another Emacs character-set extension is 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 (different from M-a, but they are normally equivalent in Emacs), M-<RET>, and M-C-a. That last means a with both the <CTRL> and <META> modifiers. We usually write it as C-M-a rather than M-C-a, for reasons of tradition.

Some terminals have a <META> key, and allow you to type Meta characters by holding this key down. Thus, you can type Meta-a by holding down <META> and pressing a. The <META> key works much like the <SHIFT> key. In fact, this key is more often labeled <ALT> or <EDIT>, instead of <META>; on a Sun keyboard, it may have a diamond on it.

If there is no <META> key, you can still type Meta characters using two-character sequences starting with <ESC>. Thus, you can enter M-a by typing <ESC> a. You can enter C-M-a by typing <ESC> C-a. Unlike <META>, which modifies other characters, <ESC> is a separate character. You don't hold down <ESC> while typing the next character; instead, you press it and release it, then you enter the next character. <ESC> is allowed on terminals with <META> keys, too, in case you have formed a habit of using it.

Emacs defines 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 graphical 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.

If your keyboard lacks one of these modifier keys, you can enter it using C-x @: C-x @ h adds the “hyper” flag to the next character, C-x @ s adds the “super” flag, and C-x @ a adds the “alt” flag. For instance, C-x @ h C-a is a way to enter Hyper-Control-a. (Unfortunately there is no way to add two modifiers by using C-x @ twice for the same character, because the first one goes to work on the C-x.)

Keyboard input includes keyboard keys that are not characters at all, such as function keys and arrow keys. Mouse buttons are also not characters. However, you can modify these events with the modifier keys <CTRL>, <META>, <SUPER>, <HYPER> and <ALT>, just like keyboard characters.

Input characters and non-character inputs are collectively called input events. See (elisp)Input Events section `Input Events' in The Emacs Lisp Reference Manual, for the full Lisp-level details. If you are not doing Lisp programming, but simply want to redefine the meaning of some characters or non-character events, see 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 catch these special sequences and convert them to function key events before any other part of Emacs gets to see them.

On graphical displays, the window manager is likely to block the character Meta-<TAB> before Emacs can see it. It may also block Meta-<SPC>, C-M-d and C-M-l. If you have these problems, we recommend that you customize your window manager to turn off those commands, or put them on key combinations that Emacs does not use.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.