To start defining a
F3 or C-x (. The abbreviation
Def appears on the mode line, showing that you are
in macro definition mode. In this mode, Emacs records all the
keystrokes that you type, whether they are commands or literal text,
so that you can replay them later. To end the macro, press F4 or C-x );
you leave macro definition mode, and Emacs stops recording your
keystrokes. Emacs also stops recording your keystrokes automatically
if an error occurs or if you press C-g.
While you’re defining a macro, Emacs acts on your keystrokes as well as recording them: that is, anything you type while in macro definition mode is treated as a regular command and executed. While you’re defining a macro, you’re doing completely normal editing. That way you can see that the macro does exactly what you want it to, and you can cancel it (with C-g) if you notice that the macro isn’t really quite what you want.
To execute your macro, press F4 or C-x e. Emacs then replays your keystrokes exactly. (You can see that F4 has two different functions relating to macros: to end a macro definition and, after it’s defined, to execute the macro.)
This macro is referred to as the “last” keyboard macro, with last here meaning most recent. Only one macro is the last keyboard macro. A macro ring, much like the kill ring, allows you to access a number of macros during an Emacs session.
Table 6-1 shows the steps required to define and execute a macro. This macro takes a list of names ...