emacs version of smartchr.vim