Fixed recursion in emacs function