diff options
| author | Stefan Monnier | 2014-05-27 01:01:49 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-05-27 01:01:49 -0400 |
| commit | a366fbe2b77958df12824da799d65a127b14e834 (patch) | |
| tree | 7316e98d4bdb265ca9a133c1dc40b0ff23b9c3d3 | |
| parent | ca0279be7037b3f8bf659ef8b073ea847d0d8553 (diff) | |
| download | emacs-a366fbe2b77958df12824da799d65a127b14e834.tar.gz emacs-a366fbe2b77958df12824da799d65a127b14e834.zip | |
* 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
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/mouse.el | 46 |
2 files changed, 37 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 594feb08980..080e11ad01f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-05-27 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * mouse.el (mouse-set-region): Handle spurious drag events (bug#17562). | ||
| 4 | (mouse-drag-track): Annotate `mouse-drag-start' so we know we moved. | ||
| 5 | |||
| 1 | 2014-05-26 Andreas Schwab <schwab@linux-m68k.org> | 6 | 2014-05-26 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 7 | ||
| 3 | * cus-face.el (custom-face-attributes): Add :distant-foreground. | 8 | * cus-face.el (custom-face-attributes): Add :distant-foreground. |
| @@ -24,8 +29,8 @@ | |||
| 24 | Todo file, make sure we're in the right mode and the buffer local | 29 | Todo file, make sure we're in the right mode and the buffer local |
| 25 | variables are set. | 30 | variables are set. |
| 26 | (todo-make-categories-list, todo-reset-nondiary-marker) | 31 | (todo-make-categories-list, todo-reset-nondiary-marker) |
| 27 | (todo-reset-done-string, todo-reset-comment-string): After | 32 | (todo-reset-done-string, todo-reset-comment-string): |
| 28 | processing all Todo files, kill the buffers of those files that | 33 | After processing all Todo files, kill the buffers of those files that |
| 29 | weren't being visited before the processing. | 34 | weren't being visited before the processing. |
| 30 | (todo-display-as-todo-file, todo-add-to-buffer-list) | 35 | (todo-display-as-todo-file, todo-add-to-buffer-list) |
| 31 | (todo-visit-files-commands): Comment out. | 36 | (todo-visit-files-commands): Comment out. |
| @@ -88,8 +93,8 @@ | |||
| 88 | 93 | ||
| 89 | 2014-05-26 Dmitry Gutov <dgutov@yandex.ru> | 94 | 2014-05-26 Dmitry Gutov <dgutov@yandex.ru> |
| 90 | 95 | ||
| 91 | * emacs-lisp/package.el (package--download-one-archive): Use | 96 | * emacs-lisp/package.el (package--download-one-archive): |
| 92 | `write-region' instead of `save-buffer' to avoid running various | 97 | Use `write-region' instead of `save-buffer' to avoid running various |
| 93 | hooks. (Bug#17155) | 98 | hooks. (Bug#17155) |
| 94 | (describe-package-1): Same. Insert newline at the end of the | 99 | (describe-package-1): Same. Insert newline at the end of the |
| 95 | buffer if appropriate. | 100 | buffer if appropriate. |
diff --git a/lisp/mouse.el b/lisp/mouse.el index 15f89291af9..d1ab6c24565 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -550,13 +550,20 @@ command alters the kill ring or not." | |||
| 550 | (end (posn-point (event-end click))) | 550 | (end (posn-point (event-end click))) |
| 551 | (click-count (event-click-count click))) | 551 | (click-count (event-click-count click))) |
| 552 | (let ((drag-start (terminal-parameter nil 'mouse-drag-start))) | 552 | (let ((drag-start (terminal-parameter nil 'mouse-drag-start))) |
| 553 | ;; Drag events don't come with a click count, sadly, so we hack | ||
| 554 | ;; our way around this problem by remembering the start-event in | ||
| 555 | ;; `mouse-drag-start' and fetching the click-count from there. | ||
| 556 | (when drag-start | 553 | (when drag-start |
| 554 | ;; Drag events don't come with a click count, sadly, so we hack | ||
| 555 | ;; our way around this problem by remembering the start-event in | ||
| 556 | ;; `mouse-drag-start' and fetching the click-count from there. | ||
| 557 | (when (and (<= click-count 1) | 557 | (when (and (<= click-count 1) |
| 558 | (equal beg (posn-point (event-start drag-start)))) | 558 | (equal beg (posn-point (event-start drag-start)))) |
| 559 | (setq click-count (event-click-count drag-start))) | 559 | (setq click-count (event-click-count drag-start))) |
| 560 | ;; Occasionally we get spurious drag events where the user hasn't | ||
| 561 | ;; dragged his mouse, but instead Emacs has dragged the text under the | ||
| 562 | ;; user's mouse. Try to recover those cases (bug#17562). | ||
| 563 | (when (and (equal (posn-x-y (event-start click)) | ||
| 564 | (posn-x-y (event-end click))) | ||
| 565 | (not (eq (car drag-start) 'mouse-movement))) | ||
| 566 | (setq end beg)) | ||
| 560 | (setf (terminal-parameter nil 'mouse-drag-start) nil))) | 567 | (setf (terminal-parameter nil 'mouse-drag-start) nil))) |
| 561 | (when (and (integerp beg) (integerp end)) | 568 | (when (and (integerp beg) (integerp end)) |
| 562 | (let ((range (mouse-start-end beg end (1- click-count)))) | 569 | (let ((range (mouse-start-end beg end (1- click-count)))) |
| @@ -820,22 +827,25 @@ The region will be defined with mark and point." | |||
| 820 | (lambda (event) (interactive "e") | 827 | (lambda (event) (interactive "e") |
| 821 | (let* ((end (event-end event)) | 828 | (let* ((end (event-end event)) |
| 822 | (end-point (posn-point end))) | 829 | (end-point (posn-point end))) |
| 823 | (unless (eq end-point start-point) | 830 | (unless (eq end-point start-point) |
| 824 | ;; As soon as the user moves, we can re-enable auto-hscroll. | 831 | ;; As soon as the user moves, we can re-enable auto-hscroll. |
| 825 | (setq auto-hscroll-mode auto-hscroll-mode-saved)) | 832 | (setq auto-hscroll-mode auto-hscroll-mode-saved) |
| 826 | (if (and (eq (posn-window end) start-window) | 833 | ;; And remember that we have moved, so mouse-set-region can know |
| 827 | (integer-or-marker-p end-point)) | 834 | ;; its event is really a drag event. |
| 828 | (mouse--drag-set-mark-and-point start-point | 835 | (setcar start-event 'mouse-movement)) |
| 829 | end-point click-count) | 836 | (if (and (eq (posn-window end) start-window) |
| 830 | (let ((mouse-row (cdr (cdr (mouse-position))))) | 837 | (integer-or-marker-p end-point)) |
| 831 | (cond | 838 | (mouse--drag-set-mark-and-point start-point |
| 832 | ((null mouse-row)) | 839 | end-point click-count) |
| 833 | ((< mouse-row top) | 840 | (let ((mouse-row (cdr (cdr (mouse-position))))) |
| 834 | (mouse-scroll-subr start-window (- mouse-row top) | 841 | (cond |
| 835 | nil start-point)) | 842 | ((null mouse-row)) |
| 836 | ((>= mouse-row bottom) | 843 | ((< mouse-row top) |
| 837 | (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) | 844 | (mouse-scroll-subr start-window (- mouse-row top) |
| 838 | nil start-point)))))))) | 845 | nil start-point)) |
| 846 | ((>= mouse-row bottom) | ||
| 847 | (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) | ||
| 848 | nil start-point)))))))) | ||
| 839 | map) | 849 | map) |
| 840 | t (lambda () | 850 | t (lambda () |
| 841 | (setq track-mouse nil) | 851 | (setq track-mouse nil) |