ANSI escaping is a mess (or, why Emacs adds [] to my file?)

Table of Contents 1. Why? 2. A Tale of Two Takes 2.1. Emacs Keymaps 2.2. The Evil Approach 2.2.1. menu-item : Menus Implemented As Keymaps 2.2.2. Evil Fixes To M-[ and M-O 2.3. The Workaround Approach 3. Afterwords So I've long been puzzled by this behavior of my Emacs config: sometimes when I open a file in the terminal with Emacs, it adds a pair of square brackets around the current…