Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 23: Binding Keys and Creating Menus

Previous HourNext Hour

Sections in this Hour:

 

Hour 23
Binding Keys and Creating Menus

Emacs is a peculiar editor in the sense that it lets you configure everything in your sight: programming modes, syntax highlighting (the color of the buffer's text), external process communication, timers, calendars, appointments, and even your keyboard layout and installed menus. Default Emacs installation comes with a lot of shortcut command keybindings preconfigured. You can find out how many preset commands there are by calling C-h m (describe-bindings). Figure 23.1 shows the first of nearly 600 possible commands.

The command C-h m (describe-bindings) lists all known bindings that are active in the current buffer. Before you go farther, you must define some terms that you use from now on. A keypress represents an input event to Emacs. An input event can be a single character, a function key, a keypad key, mouse button click, mouse dragging, and so on.

Figure 23.1
Output of describe-bindings.

Keyboard Modifiers

Did you know that one of the acronyms invented for Emacs is Escape, Meta, Alt, Control, Shift?

This leads us to talk about the modifiers that you can apply to the events. Emacs has several modifiers, but not all keyboards support the modifier keys Emacs can accept:

Notice that both Esc and Alt can generate the Meta-modifier and in some keyboards, typically in UNIX, you might have an Alt key, but to configure it to generate an Alt-modifier is sometimes a pretty hard job. Contact your system administrator or someone who knows how to configure keyboard layout under X using programs such as xmodmap(1)--the standard keymap control program--or xkeycaps(1)--which can be found easily with, for example, the AltaVista search engine. Check also the Linux Keyboard-and-Console-HOWTO document at sunsite.sunc.edu.

So you have input events and modifiers mapped to them so that you can press Alt and the character "a" to generate the key sequence Alt-a. You can also make more complex key sequences if you press and hold Ctrl, press and hold Alt, press and hold Shift, and hit "a" to generate a key sequence that reads M-C-a near the bottom of window. Notice that the Alt key here is known as the Meta-modifier. It could also read A-C-a in a different keyboard.

Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 23: Binding Keys and Creating Menus

Previous HourNext Hour

Sections in this Hour: