Subject: bug#68765: 30.0.50; Adding window-tool-bar package.

From: Jared Finder <[email-masked]>
Date: Sat, 18 May 2024 20:55:38 -0700

On 2024-05-18 02:50, Eli Zaretskii wrote:
> 
> Byte-compiling emits some warnings:
> 
>   In toplevel form:
>   window-tool-bar.el:341:21: Warning: `mouse-wheel-down-event' is an 
> obsolete variable (as of 30.1); use `mouse-wheel-buttons' instead.
>   window-tool-bar.el:341:44: Warning: `mouse-wheel-up-event' is an 
> obsolete variable (as of 30.1); use `mouse-wheel-buttons' instead.
>   window-tool-bar.el:342:21: Warning: `mouse-wheel-left-event' is an 
> obsolete variable (as of 30.1); use `mouse-wheel-buttons' instead.
>   window-tool-bar.el:342:44: Warning: `mouse-wheel-right-event' is an 
> obsolete variable (as of 30.1); use `mouse-wheel-buttons' instead.
> 
> Jared, could you please take care of these?
> 
> Thanks.

The attached patch fixes those warnings.

   -- MJF

From f8b0f612fbb5ffbf7a8ff29f2b252203ff83dcda Mon Sep 17 00:00:00 2001
From: Jared Finder <[email-masked]>
Date: Sat, 18 May 2024 20:51:09 -0700
Subject: [PATCH] Fix byte compiler warnings

* lisp/window-tool-bar.el (window-tool-bar--static-if)
(window-tool-bar--ignored-event-types): Avoid byte compiler
seeing variables obsolete in Emacs 30 and up.
---
 lisp/window-tool-bar.el | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/lisp/window-tool-bar.el b/lisp/window-tool-bar.el
index 640deccdd61..395aa3aa9cc 100644
--- a/lisp/window-tool-bar.el
+++ b/lisp/window-tool-bar.el
@@ -335,15 +335,34 @@ window-tool-bar--ignore
   (interactive)
   nil)
 
+;; static-if was added in Emacs 30, but this packages supports earlier
+;; versions.
+(defmacro window-tool-bar--static-if (condition then-form &rest else-forms)
+  "A conditional compilation macro.
+Evaluate CONDITION at macro-expansion time.  If it is non-nil,
+expand the macro to THEN-FORM.  Otherwise expand it to ELSE-FORMS
+enclosed in a `progn' form.  ELSE-FORMS may be empty."
+  (declare (indent 2)
+           (debug (sexp sexp &rest sexp)))
+  (if (eval condition lexical-binding)
+      then-form
+    (cons 'progn else-forms)))
+
 (defvar window-tool-bar--ignored-event-types
-  (let ((list (list 'mouse-movement 'pinch
-                    'wheel-down 'wheel-up 'wheel-left 'wheel-right
+  (let ((list (append
+               '(mouse-movement pinch
+                 wheel-down wheel-up wheel-left wheel-right)
+               ;; Prior to emacs 30, wheel events could also surface as
+               ;; mouse-<NUM> buttons.
+               (window-tool-bar--static-if (version< emacs-version "30")
+                   (list
                     mouse-wheel-down-event mouse-wheel-up-event
                     mouse-wheel-left-event mouse-wheel-right-event
                     (bound-and-true-p mouse-wheel-down-alternate-event)
                     (bound-and-true-p mouse-wheel-up-alternate-event)
                     (bound-and-true-p mouse-wheel-left-alternate-event)
-                    (bound-and-true-p mouse-wheel-right-alternate-event))))
+                    (bound-and-true-p mouse-wheel-right-alternate-event))
+                 nil))))
     (delete-dups (delete nil list)))
   "Cache for `window-tool-bar--last-command-triggers-refresh-p'.")
 
-- 
2.39.2