Commit a366fbe2 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/mouse.el (mouse-set-region): Handle spurious drag events.

(mouse-drag-track): Annotate `mouse-drag-start' so we know we moved.

Fixes: debbugs:17562
parent ca0279be
2014-05-27 Stefan Monnier <monnier@iro.umontreal.ca>
* mouse.el (mouse-set-region): Handle spurious drag events (bug#17562).
(mouse-drag-track): Annotate `mouse-drag-start' so we know we moved.
2014-05-26 Andreas Schwab <schwab@linux-m68k.org> 2014-05-26 Andreas Schwab <schwab@linux-m68k.org>
* cus-face.el (custom-face-attributes): Add :distant-foreground. * cus-face.el (custom-face-attributes): Add :distant-foreground.
...@@ -24,8 +29,8 @@ ...@@ -24,8 +29,8 @@
Todo file, make sure we're in the right mode and the buffer local Todo file, make sure we're in the right mode and the buffer local
variables are set. variables are set.
(todo-make-categories-list, todo-reset-nondiary-marker) (todo-make-categories-list, todo-reset-nondiary-marker)
(todo-reset-done-string, todo-reset-comment-string): After (todo-reset-done-string, todo-reset-comment-string):
processing all Todo files, kill the buffers of those files that After processing all Todo files, kill the buffers of those files that
weren't being visited before the processing. weren't being visited before the processing.
(todo-display-as-todo-file, todo-add-to-buffer-list) (todo-display-as-todo-file, todo-add-to-buffer-list)
(todo-visit-files-commands): Comment out. (todo-visit-files-commands): Comment out.
...@@ -88,8 +93,8 @@ ...@@ -88,8 +93,8 @@
2014-05-26 Dmitry Gutov <dgutov@yandex.ru> 2014-05-26 Dmitry Gutov <dgutov@yandex.ru>
* emacs-lisp/package.el (package--download-one-archive): Use * emacs-lisp/package.el (package--download-one-archive):
`write-region' instead of `save-buffer' to avoid running various Use `write-region' instead of `save-buffer' to avoid running various
hooks. (Bug#17155) hooks. (Bug#17155)
(describe-package-1): Same. Insert newline at the end of the (describe-package-1): Same. Insert newline at the end of the
buffer if appropriate. buffer if appropriate.
......
...@@ -550,13 +550,20 @@ command alters the kill ring or not." ...@@ -550,13 +550,20 @@ command alters the kill ring or not."
(end (posn-point (event-end click))) (end (posn-point (event-end click)))
(click-count (event-click-count click))) (click-count (event-click-count click)))
(let ((drag-start (terminal-parameter nil 'mouse-drag-start))) (let ((drag-start (terminal-parameter nil 'mouse-drag-start)))
;; Drag events don't come with a click count, sadly, so we hack
;; our way around this problem by remembering the start-event in
;; `mouse-drag-start' and fetching the click-count from there.
(when drag-start (when drag-start
;; Drag events don't come with a click count, sadly, so we hack
;; our way around this problem by remembering the start-event in
;; `mouse-drag-start' and fetching the click-count from there.
(when (and (<= click-count 1) (when (and (<= click-count 1)
(equal beg (posn-point (event-start drag-start)))) (equal beg (posn-point (event-start drag-start))))
(setq click-count (event-click-count drag-start))) (setq click-count (event-click-count drag-start)))
;; Occasionally we get spurious drag events where the user hasn't
;; dragged his mouse, but instead Emacs has dragged the text under the
;; user's mouse. Try to recover those cases (bug#17562).
(when (and (equal (posn-x-y (event-start click))
(posn-x-y (event-end click)))
(not (eq (car drag-start) 'mouse-movement)))
(setq end beg))
(setf (terminal-parameter nil 'mouse-drag-start) nil))) (setf (terminal-parameter nil 'mouse-drag-start) nil)))
(when (and (integerp beg) (integerp end)) (when (and (integerp beg) (integerp end))
(let ((range (mouse-start-end beg end (1- click-count)))) (let ((range (mouse-start-end beg end (1- click-count))))
...@@ -820,22 +827,25 @@ The region will be defined with mark and point." ...@@ -820,22 +827,25 @@ The region will be defined with mark and point."
(lambda (event) (interactive "e") (lambda (event) (interactive "e")
(let* ((end (event-end event)) (let* ((end (event-end event))
(end-point (posn-point end))) (end-point (posn-point end)))
(unless (eq end-point start-point) (unless (eq end-point start-point)
;; As soon as the user moves, we can re-enable auto-hscroll. ;; As soon as the user moves, we can re-enable auto-hscroll.
(setq auto-hscroll-mode auto-hscroll-mode-saved)) (setq auto-hscroll-mode auto-hscroll-mode-saved)
(if (and (eq (posn-window end) start-window) ;; And remember that we have moved, so mouse-set-region can know
(integer-or-marker-p end-point)) ;; its event is really a drag event.
(mouse--drag-set-mark-and-point start-point (setcar start-event 'mouse-movement))
end-point click-count) (if (and (eq (posn-window end) start-window)
(let ((mouse-row (cdr (cdr (mouse-position))))) (integer-or-marker-p end-point))
(cond (mouse--drag-set-mark-and-point start-point
((null mouse-row)) end-point click-count)
((< mouse-row top) (let ((mouse-row (cdr (cdr (mouse-position)))))
(mouse-scroll-subr start-window (- mouse-row top) (cond
nil start-point)) ((null mouse-row))
((>= mouse-row bottom) ((< mouse-row top)
(mouse-scroll-subr start-window (1+ (- mouse-row bottom)) (mouse-scroll-subr start-window (- mouse-row top)
nil start-point)))))))) nil start-point))
((>= mouse-row bottom)
(mouse-scroll-subr start-window (1+ (- mouse-row bottom))
nil start-point))))))))
map) map)
t (lambda () t (lambda ()
(setq track-mouse nil) (setq track-mouse nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment