Emacs input mode refactoring.