Subject: Re: bug#16988: 24.3.50; emacs -nw -Q --eval '(kill-emacs)' takes 2 seconds unless I hit a key

From: Stefan Monnier <[email-masked]>
Date: Tue, 25 Mar 2014 22:44:18 -0400

> With latest trunk:
> $ time src/emacs -nw -Q --eval '(kill-emacs)'
> real	0m2.064s
> user	0m0.030s
> sys	0m0.010s
> If however I hit a key, emacs exits immediately.

The patch below works for me, but I'm not sure if the terminal type and
version returned by gnome-terminal is "stable" or not.
Can you confirm it fixes your problem as well?

        Stefan

=== modified file 'lisp/term/xterm.el'
--- lisp/term/xterm.el	2014-03-01 18:12:16 +0000
+++ lisp/term/xterm.el	2014-03-26 02:42:05 +0000
@@ -503,6 +503,9 @@
     ;; Since xterm-280, the terminal type (NUMBER1) is now 41 instead of 0.
     (when (string-match "\\([0-9]+\\);\\([0-9]+\\);0" str)
       (let ((version (string-to-number (match-string 2 str))))
+        ;; Hack attack!  bug#16988: gnome-terminal reports "1;3409;0" but is
+        ;; based on a rather old xterm code.
+        (when (equal str "1;3409;0") (setq version 200))
         ;; If version is 242 or higher, assume the xterm supports
         ;; reporting the background color (TODO: maybe earlier
         ;; versions do too...)