Subject: bug#36879: 26.2; OSC 52 paste in term/xterm.el not working

From: Daniel Eklöf <[email-masked]>
Date: Sat, 03 Aug 2019 15:40:06 +0200

> Emacs uses BEL (C-g) as INTR char, which means that not
> only is special effort required to avoid having it quit the current
> elisp code -- this could have been done using inhibit-quit -- but when
> the pty receives the BEL from XTerm, it immediately discards unread
> characters and raises SIGINT.

I did figure Emacs, at the very least, handled BEL differently, but I
wasn't aware the PTY would discard unread characters. Thanks for
clarifying.

> Thus, it's very much a race: the only way it could ever work would be
> if Emacs has been able to read the entire reply except the BEL, and be
> sitting inside (read-char) when the BEL reaches the pty. Needless to
> say, this is rather unlikely.

Never happened during my tests :)

> Since XTerm parrots our choice of string terminator (BEL or ST), this
> suggests a simpler solution: just use ST, and the trouble with BEL is
> no more. Unfortunately the code has provisions for screen/tmux, where
> the entire request is wrapped in a DCS request:
>
>  ESC P ... ESC \
>
> which means that we cannot use ST as terminator in that case.

I came to the same conclusion, and wrote a proof-of-concept patch that
replaced BEL with ST, and verified that yes, that does indeed work. In
XTerm as well as in my not-fancy terminal. (I didn't bother removing
support for screen though, making it both a broken patch, and cruder
than yours :) )

(Förresten, hej Mattias! Det var lite oväntat...)

--
Daniel