Whenever I start the terminal emacs and there is typeahead (i.e., I start typing before emacs starts), the escape code 0;95;0c gets inserted into the buffer. For example, if I run

sleep 3; emacs -Q test

and type qwerty while the sleep is happening (test is a new file), the buffer will open with


The *Messages* buffer says

For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)
M-[ > is undefined
Making completion list...

My $TERM is xterm-256color and I am using iTerm2 on OS X 10.10.5.

EDIT: If I use Terminal.app instead of iTerm2, I get 1;2c in place of 0;95;0c and it opens a help buffer with "Global bindings starting with M-[". Not sure what key sequence activates that.

How can I determine what this escape code is and make it not get inserted into my emacs buffers?

  • The reason is probably the mismatch between declared and actual terminal. Try using "correct" values for $TERM: iterm for iTerm, and nsterm for Terminal.app. – angus Sep 29 '15 at 0:09
  • Is iterm a real TERM? When I do that emacs won't start (Cannot open terminfo database file). – asmeurer Sep 29 '15 at 16:42
  • Try iTerm.app; it's an alias. Or look into /usr/share/terminfo/i/ (or the MacOSX equivalent) and see if there is anything adequate there. – angus Sep 29 '15 at 20:11
  • I'm really not following what you're suggesting. Also note that I'm using iTerm2, not iTerm (which is defunct). – asmeurer Sep 29 '15 at 21:04

I figured it out. It is coming from the xterm-extra-capabilities setting, which by default does a check, which sends the "\e[>0c" code. I can confirm that echo -e "\e[>0c" in iTerm2 prints 0;95;0c to the typeahead. See also http://invisible-island.net/xterm/ctlseqs/ctlseqs.html (search for CSI > Ps c).

Customizing xterm-extra-capabilities and setting the capabilities manually makes the problem go away.

I'm not clear if this is a bug in iTerm2 or emacs (I don't know how to debug the terminal to see if it is sending the CSI codes properly).

  • Does changing xterm-query-timeout affect anything? – npostavs Apr 13 '18 at 0:21
  • @npostavs interesting. It seems it does. However, there must be some bug here. If I set it to some very large number, like 30 (the default value is 2), I still get the 0;95;0c (my emacs takes maybe 3-5 seconds tops to start). But if I set it to nil the bug goes away. I'm worried there could be adverse side effects to removing the timeout, though. Usually timeouts are there for a reason. – asmeurer Apr 16 '18 at 18:59
  • 1
    There is a comment in xterm--query saying "Maybe we could always use the asynchronous approach, but it's less tested." In other words, the timeout was left in because of worries about adverse side effects. But there aren't any known problems for the asynch method (as far as I can see). – npostavs May 9 '18 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.