From c22f24f6ef76b6bc62bbaafb0b1423bff3d867d4 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 5 May 2014 19:50:20 -0400 Subject: [PATCH] * lisp/xt-mouse.el (xterm-mouse--read-event-sequence-1000): Always store button numbers in the same way in xterm-mouse-last; Don't burp is xterm-mouse-last is not set as expected. Never return negative indices. Fixes: debbugs:17378 --- lisp/ChangeLog | 7 +++++++ lisp/xt-mouse.el | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7c838a61fe5..043a0c240b1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-05-05 Stefan Monnier + + * xt-mouse.el (xterm-mouse--read-event-sequence-1000): (bug#17378) + Always store button numbers in the same way in xterm-mouse-last; + Don't burp is xterm-mouse-last is not set as expected. + Never return negative indices. + 2014-05-05 Dmitry Gutov * progmodes/ruby-mode.el (ruby-syntax-propertize-function): diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 26a07b46840..87e65f7e117 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -161,10 +161,10 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (cond ((>= code 64) (format "mouse-%d" (- code 60))) ((memq code '(8 9 10)) - (setq xterm-mouse-last code) + (setq xterm-mouse-last (- code 8)) (format "M-down-mouse-%d" (- code 7))) ((= code 11) - (format "M-mouse-%d" (- xterm-mouse-last 7))) + (format "M-mouse-%d" (+ 1 (or xterm-mouse-last 0)))) ((= code 3) ;; For buttons > 5 xterm only reports a ;; button-release event. Avoid error by mapping @@ -174,8 +174,8 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (setq xterm-mouse-last code) (format "down-mouse-%d" (+ 1 code)))))) ;; x and y coordinates - (- (read-event) 33) - (- (read-event) 33))) + (max 0 (- (read-event) 33)) + (max 0 (- (read-event) 33)))) ;; XTerm's 1006-mode terminal mouse click reporting has the form ;;