Subject: bug#35180: 27.0.50; emacs daemon and “package” often inserts [I when opening file

From: Han Boetes <[email-masked]>
Date: Sun, 5 May 2019 01:07:29 +0200

To summarize my latest finds:
  This problem occurs only with terminator, tilix and gnome-terminal,
not with xterm and rxvt
  This problem does not occur when using tmux in terminator
So it looks like the use of TERM=xterm* in gnome-terminal triggers the
problem. Both tilix and terminator use gnome-terminal as backends IIRC

On Sat, Apr 27, 2019 at 10:35 PM Han Boetes <[email-masked]> wrote:
>
> I was wondering if this is a bug in emacs, or in gnome-terminal/terminator, since this doesn’t happen with xterm. And do I think this is a bug in emacs because while reading the strace output, the write line which causes the bug:
>    “\33[45d\33[K\33[2d\33[?25l[I\33[44;7H\33[30m”
> should contain: “\33[I”
> where in the output it shows: “[I”
> missing the “\33”
>
> Here I grepped for ‘write(8,’ in the strace output. What I did was:
>   rm file2 ; pkill emacs ; strace -f -o file2 /usr/local/bin/emacs -Q –daemon
> And then from another terminal:
>   emacsclient -t ‘.emacs/init.el’
> Then: x-c x-k
> And after that run
>   emacsclient -t ‘.emacs/init.el’ again, knowing this time the buffer would have focus and won’t get the ‘[I’ inserted. I’ve indented the 2 most important lines.
>
> han@janis ~ % grep 'write\(8,' file2
> 16051 write(8, "\33[?1049h\33[22;0;0t\33[?12;25h\33[?1h\33"..., 33) = 33
> 16051 write(8, "\33[>0c", 5)            = 5
> 16051 write(8, "\33[?2004h", 8)         = 8
> 16051 write(8, "\33[?1004h", 8)         = 8
> 16051 write(8, "\33[H\33[2J", 7)        = 7
> 16051 write(8, "\33[44d\33[?25l\33[30m\33[48;5;250m-UU-:"..., 207) = 207
> 16051 write(8, "\33[45d\33[?25lWhen done with a buff"..., 164) = 164
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 68) = 68
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 68) = 68
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 229) = 229
>   16051 write(8, “\33[45d\33[K\33[2d\33[?25l[I\33[44;7H\33[30m”…, 80) = 80
> 16051 write(8, "\33[45;1H\33[?25l\33[38;5;20mKill buff"..., 105) = 105
> 16051 write(8, "\33[45;32H\33[?12l\33[?25h\33[?12;25h", 29) = 29
> 16051 write(8, "\r", 1)                 = 1
> 16051 write(8, "\33[?25l\33[38;5;20mBuffer init.el m"..., 74) = 74
> 16051 write(8, "\33[?12l\33[?25h\33[?12;25h", 21) = 21
> 16051 write(8, "\33[?25ly\33[?12l\33[?25h\33[?12;25h", 28) = 28
> 16051 write(8, "\r", 1)                 = 1
> 16051 write(8, "\7", 1)                 = 1
> 16051 write(8, "\33[?25lPlease answer yes or no.\33["..., 60) = 60
> 16051 write(8, "\33[45;1H\33[?25l\33[38;5;20mBuffer in"..., 81) = 81
> 16051 write(8, "\33[?12l\33[?25h\33[?12;25h", 21) = 21
> 16051 write(8, "\33[?25ly\33[?12l\33[?25h\33[?12;25h", 28) = 28
> 16051 write(8, "\33[?25le\33[?12l\33[?25h\33[?12;25h", 28) = 28
> 16051 write(8, "\33[?25ls\33[?12l\33[?25h\33[?12;25h", 28) = 28
> 16051 write(8, "\r", 1)                 = 1
> 16051 write(8, "\33[K", 3)              = 3
> 16051 write(8, "\33[?1004l\33[?2004l\33[?1l\33>\33[?12l\33[?"..., 61) = 61
> 16051 write(8, "\33[?1049h\33[22;0;0t\33[?12;25h\33[?1h\33"..., 33) = 33
> 16051 write(8, "\33[>0c", 5)            = 5
> 16051 write(8, "\33[?2004h", 8)         = 8
> 16051 write(8, "\33[?1004h", 8)         = 8
> 16051 write(8, "\33[H\33[2J", 7)        = 7
> 16051 write(8, "\33[45d\33[?25lWhen done with a buff"..., 74) = 74
> 16051 write(8, "\33[45d\33[?25lWhen done with a buff"..., 164) = 164
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 68) = 68
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 68) = 68
> 16051 write(8, "\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K\n\33[K"..., 229) = 229
>   16051 write(8, “\33[45d\33[K\33[2d”, 12) = 12
> 16051 write(8, "\33[45d\33[?25l\33[38;5;20mKill buffer"..., 103) = 103
> 16051 write(8, "\33[45;32H\33[?12l\33[?25h\33[?12;25h", 29) = 29
> 16051 write(8, "\r", 1)                 = 1
> 16051 write(8, "\33[K", 3)              = 3
> 16051 write(8, “\33[?1004l\33[?2004l\33[?1l\33>\33[?12l\33[?”…, 61) = 61
>