In GNU Emacs in xterm-mouse-mode, dragging the mouse inserts some control sequences like [[[[M[[[[[M *'[M *'M *'[M )'M )'M ('[M ''M &' %'M $'M #'[M "'M ,'[M -'[M[M -' -' instead of selecting a region. This works correctly in xterm and gnome-terminal, so it could be some difference in terminal emulation. The file etc/PROBLEMS in the emacs distribution contains this: """ *** Gnome: Emacs' xterm-mouse-mode doesn't work on the Gnome terminal. A symptom of this bug is that double-clicks insert a control sequence into the buffer. The reason this happens is an apparent incompatibility of the Gnome terminal with Xterm, which also affects other programs using the Xterm mouse interface. A problem report has been filed. """ It looks like this was actually fixed in Gnome, but at least it indicates that they consider xterm-mouse-mode to work correctly and see the problems in the terminal emulators. Reproducible: Always Steps to Reproduce: 1. start emacs -Q -nw test.txt 2. M-x xterm-mouse-mode 3. drag the mouse around (click, hold, and move) Actual Results: crazy control sequences are inserted Expected Results: a region should be selected (compare with xterm or gnome-terminal)
Thanks for reporting.
Same with konsole-2.8.4 (kde-4.8.4). Emacs only turns on the simple mouse mode without dragging reporting (1000), not the dragging reporting extended one (1002). Most terminal emulators, including xterm and gnome-terminal, really only send events at mouse press and release in this case. Konsole, however, keeps sending click events whenever the mouse is dragged. I believe this confuses emacs (although it shouldn't). So I'd say both emacs and konsole are guilty. Emacs should be tolerant against this input, but konsole shouldn't send click events on mouse drag either. If you enable the extended, dragging reporting mode prior to starting emacs: echo -n $'\e[?1002h' then emacs of course doesn't understand the dragging events and prints some warnings about them, but starts behaving relatively sanely.
Git commit 027e8c150c45ad1821d828ea93545a36f7b0a5f3 by Tomaz Canabrava, on behalf of Luis Javier Merino Morán. Committed on 07/06/2021 at 18:03. Pushed by tcanabrava into branch 'master'. Don't send move events for normal mouse tracking xterm's DECSET 1000 requests justs press and release notifications, so do not send move events on this mode. M +5 -0 src/Vt102Emulation.cpp https://invent.kde.org/utilities/konsole/commit/027e8c150c45ad1821d828ea93545a36f7b0a5f3