I have bound M-[ to backward-paragraph. This causes a problem in terminal mode, whereby every time the mouse enters or leaves the frame (i.e., Emacs gains or loses focus), the characters I and O are inserted in the buffer.
To reproduce:
start vanilla emacs in terminal mode:
emacs -nw -Q bind a function to M-[:
(global-set-key "\M-[" 'backward-paragraph) move the mouse in and out of the Emacs frame.
What I see are the letters I and O inserted in the window. view-lossage shows:
ESC [ ;; backward-paragraph O ;; self-insert-command ESC [ ;; backward-paragraph I ;; self-insert-command ESC [ ;; backward-paragraph O ;; self-insert-command ESC [ ;; backward-paragraph I ;; self-insert-command ESC [ ;; backward-paragraph O ;; self-insert-command ESC [ ;; backward-paragraph I ;; self-insert-command I can still use M-[ as a keybinding - pressing it causes point to move backward as expected.
Is this a normal deficiency of terminal-mode emacs, or is it a bug?
Emacs version 27.0.50
Debian with i3 window manager
confirmed with gnome-terminal and xterm