Add a function do_action to route commands that make changes through.
It handles recording the previous action and wrapping with begin/end_undo_action.
Use do_action for rX.
Implement the . command (repeat last action).  Works with rX.
Improve whole-line pasting.
Make d and p work with ., and improve line pasting.