Subject: Re: bug#12354: 24.2; garbage inserted at the beginning of the buffer even when xterm-extra-capabilities is t

From: Vincent Lefevre <[email-masked]>
Date: Mon, 29 Jun 2015 15:47:04 +0200

On 2015-06-29 09:12:01 -0400, Stefan Monnier wrote:
> > In fact, reportBackground also yields the garbage problem.
> > So, there's a bug here:
> 
> >     (when (memq 'reportBackground xterm-extra-capabilities)
> >       (xterm--query "\e]11;?\e\\"
> >                     '(("\e]11;" .  xterm--report-background-handler))))
> 
> > If I understand correctly, there's a timeout here, but since the
> > feature is claimed to be supported, the timeout should be removed.
> 
> The timeout is present because we prefer having garbage in those
> (presumably rare) cases where the terminal answers too late, over having
> Emacs hang forever (tho it's not a hard-hang) when the terminal doesn't
> understand the request.

Won't C-g have any effect? In such a case, the user could hit C-g
then modify his settings. Or see below.

Note that reaching the timeout isn't that rare. It happened recently
to someone else here, who didn't notice and committed his changes to
the repository, with the consequence that the file could no longer be
compiled. IMHO, with the default configuration (i.e. with "check"),
Emacs should make sure that files cannot be silently corrupted.

Perhaps, in case of timeout and some data have been written to the
buffer before a cursor move, Emacs should warn about this when the
user saves the buffer (or perhaps earlier). When this happens, there
are two possibilities:

1. There is indeed garbage because the terminal was slow to respond,
   and the user removes this garbage (and he may want to increase the
   timeout value, in particular if this occurs too often).

2. No garbage, the terminal didn't respond, in which case the user may
   want to modify his configuration to avoid a timeout in all cases.

So, in either case, the warning would be beneficial to the user.

> You try the patch below, and set xterm-query-timeout to some value of
> your choosing (e.g. nil).

Thanks.

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)