Subject: Re: bug#44908: emacs -nw: view-lossage polluted by termcap / terminfo jazz

From: Eli Zaretskii <[email-masked]>
Date: Sun, 29 Nov 2020 18:36:49 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 29 Nov 2020 17:21:20 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> I get a *Help* buffer that has:
> >> 
> >>  ESC [ > ESC [ > 6 5 ; 6 2 0 1 ; 1 c ;;
> >
> > What do you have in recent-keys in that case?
> 
> emacs -Q -nw --eval '(message "%s" (recent-keys))'
> 
> gives me the following *Messages*:
> 
> [27 91 62 27 91 62 54 53 59 54 50 48 49 59 49 99]

Does the below fix the problem?  (But maybe we should still arrange
for recording these events in the dribble file? or is it impossible to
have dribble active at this point?)

diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 1a727e3..7094100 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -767,7 +767,8 @@ xterm--read-event-for-query
 By not redisplaying right away for xterm queries, we can avoid
 unsightly flashing during initialization. Give up and redisplay
 anyway if we've been waiting a little while."
-  (let ((start-time (current-time)))
+  (let ((start-time (current-time))
+        (inhibit--record-char t))
     (or (let ((inhibit-redisplay t))
           (read-event nil nil xterm-query-redisplay-timeout))
         (read-event nil nil