diff options
| author | Stefan Kangas | 2020-09-02 22:54:47 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-09-02 22:57:24 +0200 |
| commit | 77a5b696bbb4f70e23e94c8a731168a6673c8cd9 (patch) | |
| tree | f6eb8bad74f8ec909fae3497ebc8839dc4f6c349 | |
| parent | 5aa5c0372dc3cccf2676d26a17b4d5f71caf8cdc (diff) | |
| download | emacs-77a5b696bbb4f70e23e94c8a731168a6673c8cd9.tar.gz emacs-77a5b696bbb4f70e23e94c8a731168a6673c8cd9.zip | |
Fix binding mouse wheel with modifiers in buffer area
* test/lisp/mwheel-tests.el (mwheel-test--create-scroll-keys): Fix
binding mouse wheel with modifiers in buffer area, while ignoring them
for fringes, margins, etc. My previous change mistakenly ignored all
modifiers in `mouse-wheel-scroll-amount'.
* lisp/mwheel.el (mouse-wheel--create-scroll-keys): Fix test to
reflect the above.
| -rw-r--r-- | lisp/mwheel.el | 7 | ||||
| -rw-r--r-- | test/lisp/mwheel-tests.el | 20 |
2 files changed, 16 insertions, 11 deletions
diff --git a/lisp/mwheel.el b/lisp/mwheel.el index d5172ba0bf5..53a5a50bada 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el | |||
| @@ -363,8 +363,11 @@ an event used for scrolling, such as `mouse-wheel-down-event'." | |||
| 363 | 'left-fringe 'right-fringe | 363 | 'left-fringe 'right-fringe |
| 364 | 'vertical-scroll-bar 'horizontal-scroll-bar | 364 | 'vertical-scroll-bar 'horizontal-scroll-bar |
| 365 | 'mode-line 'header-line))) | 365 | 'mode-line 'header-line))) |
| 366 | (cons (vector event) ; default case: no prefix. | 366 | (if (consp binding) |
| 367 | (when (not (consp binding)) | 367 | ;; With modifiers, bind only the buffer area (no prefix). |
| 368 | (list `[(,@(car binding) ,event)]) | ||
| 369 | ;; No modifier: bind also some non-buffer areas of the screen. | ||
| 370 | (cons (vector event) | ||
| 368 | (mapcar (lambda (prefix) (vector prefix event)) prefixes))))) | 371 | (mapcar (lambda (prefix) (vector prefix event)) prefixes))))) |
| 369 | 372 | ||
| 370 | (define-minor-mode mouse-wheel-mode | 373 | (define-minor-mode mouse-wheel-mode |
diff --git a/test/lisp/mwheel-tests.el b/test/lisp/mwheel-tests.el index f2989d608b4..0e45b76c06e 100644 --- a/test/lisp/mwheel-tests.el +++ b/test/lisp/mwheel-tests.el | |||
| @@ -23,16 +23,18 @@ | |||
| 23 | (require 'mwheel) | 23 | (require 'mwheel) |
| 24 | 24 | ||
| 25 | (ert-deftest mwheel-test--create-scroll-keys () | 25 | (ert-deftest mwheel-test--create-scroll-keys () |
| 26 | (should (equal (mouse-wheel--create-scroll-keys 10 'mouse-1) | 26 | (should (equal (mouse-wheel--create-scroll-keys 10 'mouse-4) |
| 27 | '([mouse-1] | 27 | '([mouse-4] |
| 28 | [left-margin mouse-1] [right-margin mouse-1] | 28 | [left-margin mouse-4] [right-margin mouse-4] |
| 29 | [left-fringe mouse-1] [right-fringe mouse-1] | 29 | [left-fringe mouse-4] [right-fringe mouse-4] |
| 30 | [vertical-scroll-bar mouse-1] [horizontal-scroll-bar mouse-1] | 30 | [vertical-scroll-bar mouse-4] [horizontal-scroll-bar mouse-4] |
| 31 | [mode-line mouse-1] [header-line mouse-1]))) | 31 | [mode-line mouse-4] [header-line mouse-4]))) |
| 32 | ;; Don't bind modifiers outside of buffer area (e.g. for fringes). | 32 | ;; Don't bind modifiers outside of buffer area (e.g. for fringes). |
| 33 | (should (equal (mouse-wheel--create-scroll-keys '((shift) . 1) 'mouse-1) | 33 | (should (equal (mouse-wheel--create-scroll-keys '((shift) . 1) 'mouse-4) |
| 34 | '([mouse-1]))) | 34 | '([(shift mouse-4)]))) |
| 35 | (should (equal (mouse-wheel--create-scroll-keys '((control) . 9) 'mouse-7) | 35 | (should (equal (mouse-wheel--create-scroll-keys '((control) . 9) 'mouse-7) |
| 36 | '([mouse-7])))) | 36 | '([(control mouse-7)]))) |
| 37 | (should (equal (mouse-wheel--create-scroll-keys '((meta) . 5) 'mouse-5) | ||
| 38 | '([(meta mouse-5)])))) | ||
| 37 | 39 | ||
| 38 | ;;; mwheel-tests.el ends here | 40 | ;;; mwheel-tests.el ends here |