Subject: bug#14615: xterm--query results in slow -nw startup on some terminals

From: Glenn Morris <[email-masked]>
Date: Fri, 14 Jun 2013 12:20:42 -0400

Something like this? It can be made more sophisticated if in the
multiple handler case more than one handler might need to get run, but
the current code does not require that anywhere.

*** lisp/term/xterm.el	2013-05-15 23:55:41 +0000
--- lisp/term/xterm.el	2013-06-14 16:17:37 +0000
***************
*** 544,550 ****
                                   nil))))
            (setq i (1+ i)))
          (if (= i (length (car handler)))
!             (funcall (cdr handler))
            (while (> i 0)
              (push (aref (car handler) (setq i (1- i)))
                    unread-command-events)))))))
--- 544,551 ----
                                   nil))))
            (setq i (1+ i)))
          (if (= i (length (car handler)))
!             (progn (setq handlers nil)
!                    (funcall (cdr handler)))
            (while (> i 0)
              (push (aref (car handler) (setq i (1- i)))
                    unread-command-events)))))))