]> git.eshelyaron.com Git - emacs.git/commitdiff
mwheel.el: Unconditionally use the `wheel-up/down/...` events
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 12 Jan 2024 23:28:12 +0000 (18:28 -0500)
committerEshel Yaron <me@eshelyaron.com>
Sun, 21 Jan 2024 07:30:46 +0000 (08:30 +0100)
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.

(cherry picked from commit db8890b3c96289ca95e4ea3ea53f0eda1a948af6)

doc/lispref/commands.texi
etc/NEWS
lisp/completion-preview.el
lisp/edmacro.el
lisp/mwheel.el

index 10f47d736d2787820fd91e16d38b18389a2b3b66..5f840ac21ec3ee715e83881fb6e26ca43ed657a5 100644 (file)
@@ -2562,23 +2562,24 @@ non-@code{nil}.
 @vindex mouse-wheel-up-event
 @vindex mouse-wheel-down-event
 The @code{wheel-up} and @code{wheel-down} events are generated only on
-some kinds of systems.  On other systems, @code{mouse-4} and
-@code{mouse-5} are used instead.  For portable code, use the variables
-@code{mouse-wheel-up-event}, @code{mouse-wheel-up-alternate-event},
-@code{mouse-wheel-down-event} and
-@code{mouse-wheel-down-alternate-event} defined in @file{mwheel.el} to
-determine what event types to expect from the mouse wheel.
+some kinds of systems.  On other systems, other events like @code{mouse-4} and
+@code{mouse-5} are used instead.  Portable code should handle both
+@code{wheel-up} and @code{wheel-down} events as well as the events
+specified in the variables @code{mouse-wheel-up-event} and
+@code{mouse-wheel-down-event}, defined in @file{mwheel.el}.
 
 @vindex mouse-wheel-left-event
 @vindex mouse-wheel-right-event
-Similarly, some mice can generate @code{mouse-wheel-left-event} and
-@code{mouse-wheel-right-event} and can be used to scroll if
-@code{mouse-wheel-tilt-scroll} is non-@code{nil}.  However, some mice
-also generate other events at the same time as they're generating
-these scroll events which may get in the way.  The way to fix this is
-generally to unbind these events (for instance, @code{mouse-6} or
-@code{mouse-7}, but this is very hardware and operating system
-dependent).
+The same holds for the  horizontal wheel movements which are usually
+represented by @code{wheel-left} and @code{wheel-right} events, but
+for which portable code should also obey the variables
+@code{mouse-wheel-left-event} and @code{mouse-wheel-right-event},
+defined in @file{mwheel.el}.
+However, some mice also generate other events at the same time as
+they're generating these scroll events which may get in the way.
+The way to fix this is generally to unbind these events (for instance,
+@code{mouse-6} or @code{mouse-7}, but this is very hardware and
+operating system dependent).
 
 @cindex @code{pinch} event
 @item (pinch @var{position} @var{dx} @var{dy} @var{scale} @var{angle})
index ac743cd0bf10fee5c291a0ac78a2e903ebfffeee..758d5f094395361276793174ce293c00f45a61bd 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -408,6 +408,13 @@ respectively, in addition to the existing translations 'C-x 8 / e' and
 ** Trace
 In batch mode, tracing now sends the trace to stdout.
 
++++
+** Mwheel
+The 'wheel-up/down/left/right' events are now bound unconditionally,
+and the 'mouse-wheel-up/down/left/right-event' variables are thus
+used only to specify the 'mouse-4/5/6/7' events generated by
+legacy setup, such as 'xterm-mouse-mode' or X11 without XInput2.
+
 +++
 ** New command 'lldb'.
 Run the LLDB debugger, analogous to the 'gud-gdb' command.
index 3bb5ef24e9d2c1a3fa72267fff733ce2c2b401be..48b6a4fd8224b3aff9db4145aa426db2606284f6 100644 (file)
@@ -135,6 +135,8 @@ If this option is nil, these commands do not display any message."
   "<down-mouse-1>" #'completion-preview-insert
   "C-<down-mouse-1>" #'completion-at-point
   "<down-mouse-2>" #'completion-at-point
+  "<wheel-up>"     #'completion-preview-prev-candidate
+  "<wheel-down>"   #'completion-preview-next-candidate
   (key-description (vector mouse-wheel-up-event))
   #'completion-preview-prev-candidate
   (key-description (vector mouse-wheel-up-alternate-event))
index 5bd0c1892e502466db2697dcd05b5e93371df774..9ade554f5593a072b79be681f0ef681ac40eccd0 100644 (file)
@@ -748,13 +748,14 @@ This function assumes that the events can be stored in a string."
                ;; info is recorded in macros to make this possible.
                ((or (mouse-event-p ev) (mouse-movement-p ev)
                     (memq (event-basic-type ev)
-                          (list mouse-wheel-down-event mouse-wheel-up-event
-                                mouse-wheel-right-event
-                                mouse-wheel-left-event
-                                mouse-wheel-down-alternate-event
-                                mouse-wheel-up-alternate-event
-                                mouse-wheel-right-alternate-event
-                                mouse-wheel-left-alternate-event)))
+                          `( ,mouse-wheel-down-event ,mouse-wheel-up-event
+                             ,mouse-wheel-right-event
+                             ,mouse-wheel-left-event
+                             ,mouse-wheel-down-alternate-event
+                             ,mouse-wheel-up-alternate-event
+                             ,mouse-wheel-right-alternate-event
+                             ,mouse-wheel-left-alternate-event
+                             wheel-down wheel-up wheel-left wheel-right)))
                 nil)
                (noerror nil)
                (t
index 84679f5c33ff17379b9cab49c493eb81efadda43..f50376c72b576900496df24df8417de6ef39f7c1 100644 (file)
@@ -308,9 +308,11 @@ active window."
 (defmacro mwheel--is-dir-p (dir button)
   (declare (debug (sexp form)))
   (let ((custom-var (intern (format "mouse-wheel-%s-event" dir)))
-        (custom-var-alt (intern (format "mouse-wheel-%s-alternate-event" dir))))
+        (custom-var-alt (intern (format "mouse-wheel-%s-alternate-event" dir)))
+        (event (intern (format "wheel-%s" dir))))
     (macroexp-let2 nil butsym button
-      `(or (eq ,butsym ,custom-var)
+      `(or (eq ,butsym ',event)
+           (eq ,butsym ,custom-var)
            ;; We presume here `button' is never nil.
            (eq ,butsym ,custom-var-alt)))))
 
@@ -503,14 +505,16 @@ an event used for scrolling, such as `mouse-wheel-down-event'."
      ((and (consp binding) (eq (cdr binding) 'text-scale))
       (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
                            mouse-wheel-down-alternate-event
-                           mouse-wheel-up-alternate-event))
+                           mouse-wheel-up-alternate-event
+                           'wheel-down 'wheel-up))
         (when event
           (mouse-wheel--add-binding `[,(append (car binding) (list event))]
                                     'mouse-wheel-text-scale))))
      ((and (consp binding) (eq (cdr binding) 'global-text-scale))
       (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
                            mouse-wheel-down-alternate-event
-                           mouse-wheel-up-alternate-event))
+                           mouse-wheel-up-alternate-event
+                           'wheel-down 'wheel-up))
         (when event
           (mouse-wheel--add-binding `[,(append (car binding) (list event))]
                                     'mouse-wheel-global-text-scale))))
@@ -521,7 +525,8 @@ an event used for scrolling, such as `mouse-wheel-down-event'."
                            mouse-wheel-down-alternate-event
                            mouse-wheel-up-alternate-event
                            mouse-wheel-left-alternate-event
-                           mouse-wheel-right-alternate-event))
+                           mouse-wheel-right-alternate-event
+                           'wheel-down 'wheel-up 'wheel-left 'wheel-right))
         (when event
           (dolist (key (mouse-wheel--create-scroll-keys binding event))
             (mouse-wheel--add-binding key 'mwheel-scroll))))))))