[emacs] Fix hook when entering terminal