PreferredBadger672 · 2022-04-06 07:50
When I run emacs in a terminal and change focus from the terminal window, emacs will insert characters into the buffer. In an empty scratch buffer, it just entered `[O [I [O [I]]]]`. I'm pretty sure this has something to do with the terminal sending Esc [, and I have paredit-wrap-square bound to M-[.
Does anyone know how to deal with this behavior? Are there typically terminal settings to not send certain sequences, or is there something I can configure in Emacs to prevent insertion of these characters?
rpluim · 2022-04-06 09:49
Those are `focus-in` and `focus-out` events. emacs-27 and later has support for them (assuming you're running something that identifies as xterm).
PreferredBadger672 · 2022-04-06 10:15
I'm a little lost on how those events work or how to use them to prevent those inputs, but installing [https://github.com/veelenga/terminal-focus-reporting.el](https://github.com/veelenga/terminal-focus-reporting.el/blob/master/terminal-focus-reporting.el) fixes the issue for me... so I guess that's good enough for now! I'm sure there's a way to do it w/o the plugin but I'll figure it out when my brain is working :) thank you for the help!
rpluim · 2022-04-06 12:49
Looking at that package, it seems to be doing something very similar to what Emacs does. Glad you got things working.