Subject: bug#25097: 25.1; Scratch buffer flashes with emacsclient and xterm

From: Noam Postavsky <[email-masked]>
Date: Wed, 09 May 2018 20:44:28 -0400

Jake <[email-masked]> writes:

> When I run
>
>      emacs -Q --daemon
>      emacsclient -t foo.txt
>
> to open some file foo.txt, the scratch buffer displays for 2-3 seconds
> before the buffer for the file actually opens. My TERM environment
> variable is set to "xterm-256color", and if I change it to
> "screen-256color" this problem goes away. Also if I create a file
> containing only "(setq-default xterm-query-timeout nil)" and load that
> with the -l flag, the problem goes away. Presumably there is a purpose
> to this timeout, so just doing this is probably not ideal. It was
> added in commit cc8f96e in response to bug#12345.

That commit actually changed the timeout from a hardcoded 2, and makes
the timeout configurable.  So I think setting xterm-query-timeout to nil
is the right thing here.  Perhaps even a nil xterm-query-timeout should
be the default?

Here's another case where that seems to help:

https://emacs.stackexchange.com/questions/16878/0950c-escape-code-is-inserted-with-typeahead-in-terminal-emacs