Binding a macro to a key is easy. The key sequences C-x C-k 0 through 9 and capital A through Z are reserved for user macro bindings. You can choose one that strikes you as mnemonic for your macro.
For example, to bind our transpose names macro to C-x C-k T, type C-x C-k
b. Emacs prompts for the key binding. Type C-x C-k T Enter. Emacs confirms,
Keyboard macro bound to C-x C-k T
. Binding a macro
command to a key in this way works for only one session. We want to
keep this macro, so read on to find out how to make this binding
permanent.