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

From: Nicolas Richard <[email-masked]>
Date: Wed, 26 Mar 2014 11:29:11 +0100

Stefan Monnier <[email-masked]> writes:
>> 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?

Here's a patch based on COLORTERM which works for me.

diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index eac4014..bd5675b 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -503,6 +503,12 @@ The relevant features are:
     ;; 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))))
+        ;; gnome-terminal pretends to be xterm but lacks some of its
+        ;; more recent features.  See bug#16988.
+        (let ((colorterm (getenv "COLORTERM" (selected-frame))))
+          (when (and colorterm
+                     (string-match "\\`gnome-terminal" colorterm))
+            (setq version 200)))
         ;; If version is 242 or higher, assume the xterm supports
         ;; reporting the background color (TODO: maybe earlier
         ;; versions do too...)

--
Nico.