Subject: bug#68796: Stefan's wheel event change

From: Stefan Monnier <[email-masked]>
Date: Fri, 05 Apr 2024 17:22:05 -0400

>> +** Mouse wheel events should now always be 'wheel-up/down/left/right'.
>> +At those places where the old 'mouse-4/5/6/7' events could still occur
>> +(i.e. X11 input in the absence of XInput2, and `xterm-mouse-mode`),
>> +we remap them to the corresponding 'wheel-up/down/left/right' event,
>> +according to the new variable 'mouse-wheel-buttons'.
>
> Likewise here.

Fixed.

>> +(defcustom mouse-wheel-buttons
>> +  '((4 . wheel-up) (5 . wheel-down) (6 . wheel-left) (7 . wheel-right))
>> +  "Buttons to remap to wheel events.
>
> Suggest to rephrase:
>
>   "How to remap mouse button numbers to wheel events."

Thanks.

>> +This is an alist of (NUMBER . SYMBOL) used to remap old-style mouse wheel
>> +events represented as mouse button events.  It remaps mouse button event
>> +NUMBER to the event SYMBOL.  SYMBOL must be one of `wheel-up', `wheel-down',
>
> Not "mouse event NUMBER", but "mouse button NUMBER", I think.
> Alternatively, you could say "mouse button event 'mouse-NUMBER'".
> IOW, NUMBER is not a mouse event, it's a number.

Indeed.

>> +  /* Convert pre-XInput2 wheel events represented as mouse-clicks.  */
>> +  if (!xi2)
>> +    {
>> +      Lisp_Object base
>> +        = Fcdr_safe (Fassq (make_fixnum (result->code + 1),
>> +                            Fsymbol_value (Qmouse_wheel_buttons)));
>
> Should this test mouse-wheel-buttons for being bound and have a list
> value, before calling assq?  mouse.el is preloaded relatively late in
> loadup, so I think we had better played it safe, no?

AFAIK we can't get such events until *much* later, after the dump, so
I don't see any need for that.  Especially since it only affects mouse
clicks, so it wouldn't render Emacs unusable.

`Fassq` can also signal an error if `mouse-wheel-buttons` contains
something else than an alist, but in my tests, this simply results in
error messages when you use the mouse buttons/wheel, which is about as
good as it gets, IMO.

        Stefan