Subject: bug#68796: xterm.c: Convert mouse-4/5/6/7 to wheel-up/down/left/right

From: Stefan Monnier <[email-masked]>
Date: Sun, 03 Mar 2024 22:07:40 -0500

> That would be simple if I could find the FIXME, but it doesn't appear to
> be present anywhere in that patch...

[ Hmm... not sure what happened: `C-s FIXME` finds it for me:  ]

diff --git a/src/keyboard.c b/src/keyboard.c
index 1f7253a7da1..4c3e33762af 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6628,8 +6628,13 @@ make_lispy_event (struct input_event *event)
 
 	if (CONSP (event->arg))
 	  return list5 (head, position, make_fixnum (double_click_count),
-			XCAR (event->arg), Fcons (XCAR (XCDR (event->arg)),
-						  XCAR (XCDR (XCDR (event->arg)))));
+			XCAR (event->arg),
+			/* FIXME: I don't know what I'm doing here.  */
+			(CONSP (XCDR (event->arg))
+			 && CONSP (XCDR (XCDR (event->arg))))
+			? Fcons (XCAR (XCDR (event->arg)),
+			         XCAR (XCDR (XCDR (event->arg))))
+			: Qnil);
         else if (NUMBERP (event->arg))
           return list4 (head, position, make_fixnum (double_click_count),
                         event->arg);

>>> +  /* 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)));
>>> +      int wheel
>>> +        = NILP (base) ? -1
>>> +          : BASE_EQ (base, Qwheel_down)  ? 0
>>> +          : BASE_EQ (base, Qwheel_up)    ? 1
>>> +          : BASE_EQ (base, Qwheel_left)  ? 2
>>> +          : BASE_EQ (base, Qwheel_right) ? 3
>>> +          : -1;
>
> This should be surrounded by parentheses.

Ah, it might be need for CC-mode, indeed, thanks.
`sm-c-mode` gets this right without the parens :-)

        Stefan