tags 36879 patch quit Daniel Eklöf skrev: >Have I configured something wrong? Or is this a bug? I don't think you did anything wrong; I can reproduce the bug (in XTerm; I don't have your fancy emulator). The question is rather, how did this code ever work in the first place? As you observed, when XTerm sends the reply, it uses BEL as terminator. 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. 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. We could tell the tty not to discard the queue upon INTR by setting the NOFLSH flag, but (1) I don't know how portable that is, (2) it's not what we normally want when C-g is used interactively, and (3) it would still process the BEL out-of-order with respect to earlier chars. Attached is a rather heavy-handed patch which temporarily changes the quit-char to something unlikely while sending the OSC 52 request and reading the reply. It also allows the reply to be terminated by ESC \ (ST) as well. 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. However, I haven't been able to make this facility work with tmux at all, and with screen only by reverting 4183482f4d (bug#20356) AND explicitly setting TERM=screen (the default is screen.xterm-256color). In addition, changing quit-char can be visually annoying; it causes reinitialisation of the entire tty, something you don't want every time you press C-y. Perhaps it's fine to drop screen support from this particular function? I attached another, alternative patch that does that instead.