Add handling of chaning input methods with special case for emacs