aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2024-01-12 18:28:12 -0500
committerStefan Monnier2024-01-20 15:03:26 -0500
commitdb8890b3c96289ca95e4ea3ea53f0eda1a948af6 (patch)
treeaecb751048bee18b7271229c27b0b3b0c1d80172
parent82f71e106afd9bede95cfea3025f7c059d7c2bcf (diff)
downloademacs-db8890b3c96289ca95e4ea3ea53f0eda1a948af6.tar.gz
emacs-db8890b3c96289ca95e4ea3ea53f0eda1a948af6.zip
mwheel.el: Unconditionally use the `wheel-up/down/...` events
The `mouse-wheel-DIR-event` vars were introduced because under X11 we get different `mouse-N` events depending on the users' mouse and those same events can be used for other things for other rodents, so we can't unconditionally treat those events as mouse-wheel events. But this does not apply to the `wheel-up/down/...` events. So hard code them. * lisp/mwheel.el (mwheel--is-dir-p): Always consider the `wheel-DIR` events. (mouse-wheel--setup-bindings): Always bind the `wheel-DIR` events. * lisp/completion-preview.el (completion-preview--mouse-map): Unconditionally bind the `wheel-DIR` events. * lisp/edmacro.el (edmacro-fix-menu-commands): Hard code the `wheel-DIR` events as mouse events regardless of `mouse-wheel-*-event`s. * lisp/progmodes/flymake.el (flymake--mode-line-counter-map): Do nothing, because it's already been done in commit e5be6c7ae309. * doc/lispref/commands.texi (Misc Events): Document the need to use `wheel-up/down/left/right` unconditionally.
-rw-r--r--doc/lispref/commands.texi29
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/completion-preview.el2
-rw-r--r--lisp/edmacro.el15
-rw-r--r--lisp/mwheel.el15
5 files changed, 42 insertions, 26 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 10f47d736d2..5f840ac21ec 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -2562,23 +2562,24 @@ non-@code{nil}.
2562@vindex mouse-wheel-up-event 2562@vindex mouse-wheel-up-event
2563@vindex mouse-wheel-down-event 2563@vindex mouse-wheel-down-event
2564The @code{wheel-up} and @code{wheel-down} events are generated only on 2564The @code{wheel-up} and @code{wheel-down} events are generated only on
2565some kinds of systems. On other systems, @code{mouse-4} and 2565some kinds of systems. On other systems, other events like @code{mouse-4} and
2566@code{mouse-5} are used instead. For portable code, use the variables 2566@code{mouse-5} are used instead. Portable code should handle both
2567@code{mouse-wheel-up-event}, @code{mouse-wheel-up-alternate-event}, 2567@code{wheel-up} and @code{wheel-down} events as well as the events
2568@code{mouse-wheel-down-event} and 2568specified in the variables @code{mouse-wheel-up-event} and
2569@code{mouse-wheel-down-alternate-event} defined in @file{mwheel.el} to 2569@code{mouse-wheel-down-event}, defined in @file{mwheel.el}.
2570determine what event types to expect from the mouse wheel.
2571 2570
2572@vindex mouse-wheel-left-event 2571@vindex mouse-wheel-left-event
2573@vindex mouse-wheel-right-event 2572@vindex mouse-wheel-right-event
2574Similarly, some mice can generate @code{mouse-wheel-left-event} and 2573The same holds for the horizontal wheel movements which are usually
2575@code{mouse-wheel-right-event} and can be used to scroll if 2574represented by @code{wheel-left} and @code{wheel-right} events, but
2576@code{mouse-wheel-tilt-scroll} is non-@code{nil}. However, some mice 2575for which portable code should also obey the variables
2577also generate other events at the same time as they're generating 2576@code{mouse-wheel-left-event} and @code{mouse-wheel-right-event},
2578these scroll events which may get in the way. The way to fix this is 2577defined in @file{mwheel.el}.
2579generally to unbind these events (for instance, @code{mouse-6} or 2578However, some mice also generate other events at the same time as
2580@code{mouse-7}, but this is very hardware and operating system 2579they're generating these scroll events which may get in the way.
2581dependent). 2580The way to fix this is generally to unbind these events (for instance,
2581@code{mouse-6} or @code{mouse-7}, but this is very hardware and
2582operating system dependent).
2582 2583
2583@cindex @code{pinch} event 2584@cindex @code{pinch} event
2584@item (pinch @var{position} @var{dx} @var{dy} @var{scale} @var{angle}) 2585@item (pinch @var{position} @var{dx} @var{dy} @var{scale} @var{angle})
diff --git a/etc/NEWS b/etc/NEWS
index f4d008ee2d6..fefdfb2afb3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -407,6 +407,13 @@ respectively, in addition to the existing translations 'C-x 8 / e' and
407* Changes in Specialized Modes and Packages in Emacs 30.1 407* Changes in Specialized Modes and Packages in Emacs 30.1
408 408
409+++ 409+++
410** Mwheel
411The 'wheel-up/down/left/right' events are now bound unconditionally,
412and the 'mouse-wheel-up/down/left/right-event' variables are thus
413used only to specify the 'mouse-4/5/6/7' events generated by
414legacy setup, such as 'xterm-mouse-mode' or X11 without XInput2.
415
416+++
410** New command 'lldb'. 417** New command 'lldb'.
411Run the LLDB debugger, analogous to the 'gud-gdb' command. 418Run the LLDB debugger, analogous to the 'gud-gdb' command.
412 419
diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el
index 3bb5ef24e9d..48b6a4fd822 100644
--- a/lisp/completion-preview.el
+++ b/lisp/completion-preview.el
@@ -135,6 +135,8 @@ If this option is nil, these commands do not display any message."
135 "<down-mouse-1>" #'completion-preview-insert 135 "<down-mouse-1>" #'completion-preview-insert
136 "C-<down-mouse-1>" #'completion-at-point 136 "C-<down-mouse-1>" #'completion-at-point
137 "<down-mouse-2>" #'completion-at-point 137 "<down-mouse-2>" #'completion-at-point
138 "<wheel-up>" #'completion-preview-prev-candidate
139 "<wheel-down>" #'completion-preview-next-candidate
138 (key-description (vector mouse-wheel-up-event)) 140 (key-description (vector mouse-wheel-up-event))
139 #'completion-preview-prev-candidate 141 #'completion-preview-prev-candidate
140 (key-description (vector mouse-wheel-up-alternate-event)) 142 (key-description (vector mouse-wheel-up-alternate-event))
diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index 5bd0c1892e5..9ade554f559 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -748,13 +748,14 @@ This function assumes that the events can be stored in a string."
748 ;; info is recorded in macros to make this possible. 748 ;; info is recorded in macros to make this possible.
749 ((or (mouse-event-p ev) (mouse-movement-p ev) 749 ((or (mouse-event-p ev) (mouse-movement-p ev)
750 (memq (event-basic-type ev) 750 (memq (event-basic-type ev)
751 (list mouse-wheel-down-event mouse-wheel-up-event 751 `( ,mouse-wheel-down-event ,mouse-wheel-up-event
752 mouse-wheel-right-event 752 ,mouse-wheel-right-event
753 mouse-wheel-left-event 753 ,mouse-wheel-left-event
754 mouse-wheel-down-alternate-event 754 ,mouse-wheel-down-alternate-event
755 mouse-wheel-up-alternate-event 755 ,mouse-wheel-up-alternate-event
756 mouse-wheel-right-alternate-event 756 ,mouse-wheel-right-alternate-event
757 mouse-wheel-left-alternate-event))) 757 ,mouse-wheel-left-alternate-event
758 wheel-down wheel-up wheel-left wheel-right)))
758 nil) 759 nil)
759 (noerror nil) 760 (noerror nil)
760 (t 761 (t
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 84679f5c33f..f50376c72b5 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -308,9 +308,11 @@ active window."
308(defmacro mwheel--is-dir-p (dir button) 308(defmacro mwheel--is-dir-p (dir button)
309 (declare (debug (sexp form))) 309 (declare (debug (sexp form)))
310 (let ((custom-var (intern (format "mouse-wheel-%s-event" dir))) 310 (let ((custom-var (intern (format "mouse-wheel-%s-event" dir)))
311 (custom-var-alt (intern (format "mouse-wheel-%s-alternate-event" dir)))) 311 (custom-var-alt (intern (format "mouse-wheel-%s-alternate-event" dir)))
312 (event (intern (format "wheel-%s" dir))))
312 (macroexp-let2 nil butsym button 313 (macroexp-let2 nil butsym button
313 `(or (eq ,butsym ,custom-var) 314 `(or (eq ,butsym ',event)
315 (eq ,butsym ,custom-var)
314 ;; We presume here `button' is never nil. 316 ;; We presume here `button' is never nil.
315 (eq ,butsym ,custom-var-alt))))) 317 (eq ,butsym ,custom-var-alt)))))
316 318
@@ -503,14 +505,16 @@ an event used for scrolling, such as `mouse-wheel-down-event'."
503 ((and (consp binding) (eq (cdr binding) 'text-scale)) 505 ((and (consp binding) (eq (cdr binding) 'text-scale))
504 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event 506 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
505 mouse-wheel-down-alternate-event 507 mouse-wheel-down-alternate-event
506 mouse-wheel-up-alternate-event)) 508 mouse-wheel-up-alternate-event
509 'wheel-down 'wheel-up))
507 (when event 510 (when event
508 (mouse-wheel--add-binding `[,(append (car binding) (list event))] 511 (mouse-wheel--add-binding `[,(append (car binding) (list event))]
509 'mouse-wheel-text-scale)))) 512 'mouse-wheel-text-scale))))
510 ((and (consp binding) (eq (cdr binding) 'global-text-scale)) 513 ((and (consp binding) (eq (cdr binding) 'global-text-scale))
511 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event 514 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
512 mouse-wheel-down-alternate-event 515 mouse-wheel-down-alternate-event
513 mouse-wheel-up-alternate-event)) 516 mouse-wheel-up-alternate-event
517 'wheel-down 'wheel-up))
514 (when event 518 (when event
515 (mouse-wheel--add-binding `[,(append (car binding) (list event))] 519 (mouse-wheel--add-binding `[,(append (car binding) (list event))]
516 'mouse-wheel-global-text-scale)))) 520 'mouse-wheel-global-text-scale))))
@@ -521,7 +525,8 @@ an event used for scrolling, such as `mouse-wheel-down-event'."
521 mouse-wheel-down-alternate-event 525 mouse-wheel-down-alternate-event
522 mouse-wheel-up-alternate-event 526 mouse-wheel-up-alternate-event
523 mouse-wheel-left-alternate-event 527 mouse-wheel-left-alternate-event
524 mouse-wheel-right-alternate-event)) 528 mouse-wheel-right-alternate-event
529 'wheel-down 'wheel-up 'wheel-left 'wheel-right))
525 (when event 530 (when event
526 (dolist (key (mouse-wheel--create-scroll-keys binding event)) 531 (dolist (key (mouse-wheel--create-scroll-keys binding event))
527 (mouse-wheel--add-binding key 'mwheel-scroll)))))))) 532 (mouse-wheel--add-binding key 'mwheel-scroll))))))))