bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68213: 30.0.50; completion-preview-tests failure in --without-x buil


From: Stefan Monnier
Subject: bug#68213: 30.0.50; completion-preview-tests failure in --without-x build
Date: Sun, 07 Jan 2024 12:46:27 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> So in that case we need something like
>
>   (or (boundp 'mouse-wheel-up-event)
>       (defvar mouse-wheel-up-event nil))

That's basically equivalent to

    (defvar mouse-wheel-up-event nil)

But no, it would be wrong for completion-preview.el to define
mwheel.el's variables.

Instead we should either (require 'mwheel) or test `boundp` when we
*use* the variable.

Sadly, `defvar-keymap` does not offer any convenient way to specify
conditional bindings, tho we could use a hack like

    (key-description
     (vector (or (bound-and-true-p mouse-wheel-up-event)
                 'completion-preview--dummy-wheel-up)))

Overall, we can work around the limitations of `defvar-keymap` with the
ugly patch below.

> But I guess I will wait until Po Lu explains why these are defined as
> they are before doing something about this test failure.

I have the impression that `mwheel.el` should just blindly always use
`wheel-up/down/..` events (i.e. hard code them), and optionally
also obey `mouse-5/4` on those systems that need them (based on
`mouse-wheel-up/down-event` custom vars).


        Stefan


diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el
index baadb4714b1..8d7ad97d2c3 100644
--- a/lisp/completion-preview.el
+++ b/lisp/completion-preview.el
@@ -128,19 +128,31 @@ completion-preview-active-mode-map
   ;; "M-p" #'completion-preview-prev-candidate
   )
 
-(defvar mouse-wheel-up-event)
-(defvar mouse-wheel-up-alternate-event)
-(defvar mouse-wheel-down-event)
-(defvar mouse-wheel-down-alternate-event)
 (defvar-keymap completion-preview--mouse-map
   :doc "Keymap for mouse clicks on the completion preview."
   "<down-mouse-1>" #'completion-preview-insert
   "C-<down-mouse-1>" #'completion-at-point
   "<down-mouse-2>" #'completion-at-point
-  (format "<%s>" mouse-wheel-up-event)             
#'completion-preview-prev-candidate
-  (format "<%s>" mouse-wheel-up-alternate-event)   
#'completion-preview-prev-candidate
-  (format "<%s>" mouse-wheel-down-event)           
#'completion-preview-next-candidate
-  (format "<%s>" mouse-wheel-down-alternate-event) 
#'completion-preview-next-candidate)
+  (key-description (vector (or (bound-and-true-p mouse-wheel-up-event)
+                               'completion-preview--dummy-wheel-up)))
+  #'completion-preview-prev-candidate
+  (key-description
+   (vector (let ((event (bound-and-true-p mouse-wheel-up-alternate-event)))
+             (if (and event (not (eq event (bound-and-true-p
+                                            mouse-wheel-up-event))))
+                 event
+               'completion-preview--dummy-wheel-up-alt))))
+  #'completion-preview-prev-candidate
+  (key-description (vector (or (bound-and-true-p mouse-wheel-down-event)
+                               'completion-preview--dummy-wheel-down)))
+  #'completion-preview-next-candidate
+  (key-description
+   (vector (let ((event (bound-and-true-p mouse-wheel-down-alternate-event)))
+             (if (and event (not (eq event (bound-and-true-p
+                                            mouse-wheel-down-event))))
+                 event
+               'completion-preview--dummy-wheel-down-alt))))
+  #'completion-preview-next-candidate)
 
 (defvar-local completion-preview--overlay nil)
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]