A few months ago, I ran into an issue with Emacs that I just found the solution to. In Emacs term-mode (or ansi-term, or multi-term), hitting Enter doesn’t work, and the mini-buffer displays Wrong type argument: characterp, return
, and the term doesn’t see the keystroke.
I dented about it on identi.ca, and no one was able to help me. This turned out to be a mistake, because I kept seeing the dent as I Googled/DuckDuckGo’ed for a solution.
Anyway, I finally found the solution on the Korean blog Seorenn SIGSEGV.
The problem is basically that autopair had remapped the return key to an autopair function, which didn’t jive with term-mode. At least, that’s what Seorenn said.
If it were that simple, I would have noticed it when I installed autopair. Only in some environments does the problem manifest. For example, on Ubuntu, where I started using autopair, the problem never appears. When I switched to Fedora (and later Parabola), I figured it was some issue with the X server, because it worked fine when running in a terminal.
Now knowing that the problem was related to autopair, I can’t figure out how it ever worked.
Anyway, the fix is to add the following to your .emacs:
(add-hook 'term-mode-hook
#'(lambda () (setq autopair-dont-activate t)))
(Code segment from emacs-fu, via Seorenn SIGSEGV.)