M-x is command / meta
^x ( to start recording a macro
^x ) to stop recording a macro
M-x name-last-kbd-macro to name the last macro run
~/.emacs, move the cursor to the bottom of the file
M-x insert-kbd-macro to insert the lisp code for a named kmacro at the cursor position.
Save the file.
In any future emacs session,
M-x new-macro-name just like any emacs command.
# see above