]> git.eshelyaron.com Git - emacs.git/commitdiff
Take stock of the wheel-up/down confusion
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 24 Jan 2024 17:57:33 +0000 (12:57 -0500)
committerEshel Yaron <me@eshelyaron.com>
Wed, 24 Jan 2024 18:31:54 +0000 (19:31 +0100)
While we're hopefully all aware of the usual confusion between
the scroll operation moving the document or moving the viewport, Emacs
has its very own instance of that confusion where the
`mouse-wheel-down-event` variable is the one that (used to) hold
the value `wheel-up` and vice versa.

Thanks for Po Lu's commit 957b4f826a4 which not only fixed my change
but brought that confusion to my attention.
This patch doesn't fix the problem, but tries to fix the other places
in the code where we did not take it into account.

* doc/lispref/commands.texi (Misc Events): Mention the
wheel-up/down confusion.

* lisp/progmodes/flymake.el (flymake--mode-line-counter-map):
* lisp/completion-preview.el (completion-preview--mouse-map):
Fix wheel-up/down confusion.

* lisp/mwheel.el (mouse-wheel-down-event, mouse-wheel-up-event):
Fix docstrings.

(cherry picked from commit 1f3371b46e8a6a51f88c56785175b48af2a0bed7)

doc/lispref/commands.texi
lisp/completion-preview.el
lisp/mwheel.el
lisp/progmodes/flymake.el

index 5f840ac21ec3ee715e83881fb6e26ca43ed657a5..6c8d42337d03b6ded9f6b2860aafbfd2841178ec 100644 (file)
@@ -2567,6 +2567,9 @@ some kinds of systems.  On other systems, other events like @code{mouse-4} and
 @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}.
+Beware that for historical reasons the @code{mouse-wheel-@emph{up}-event}
+is the variable that holds an event that should be handled similarly to
+@code{wheel-@emph{down}} and vice versa.
 
 @vindex mouse-wheel-left-event
 @vindex mouse-wheel-right-event
index f552db7aa8e2799f778168cfa10156d2e5a9ee87..6fd60f3c4166452fee33e74c291c0b0ede3ff2b4 100644 (file)
@@ -135,12 +135,14 @@ 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
+  ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events
+  ;; and vice versa!!
   "<wheel-up>"     #'completion-preview-prev-candidate
   "<wheel-down>"   #'completion-preview-next-candidate
   (key-description (vector mouse-wheel-up-event))
-  #'completion-preview-prev-candidate
+  #'completion-preview-next-candidate
   (key-description (vector mouse-wheel-down-event))
-  #'completion-preview-next-candidate)
+  #'completion-preview-prev-candidate)
 
 (defvar-local completion-preview--overlay nil)
 
index 1e08328c8751467a79e63c7d64825aec23c60b3b..53042085bf666a244a3574a51421cafb782bda4b 100644 (file)
@@ -34,8 +34,8 @@
 ;; Implementation note:
 ;;
 ;; I for one would prefer some way of converting the mouse-4/mouse-5
-;; events into different event types, like 'mwheel-up' or
-;; 'mwheel-down', but I cannot find a way to do this very easily (or
+;; events into different event types, like 'wheel-up' or
+;; 'wheel-down', but I cannot find a way to do this very easily (or
 ;; portably), so for now I just live with it.
 
 (require 'timer)
@@ -63,14 +63,14 @@ They are sometimes generated by things like `xterm-mouse-mode' as well.")
 
 (defcustom mouse-wheel-down-event
   (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4)
-  "Event used for scrolling down, beside `wheel-down', if any."
+  "Event used for scrolling down, beside `wheel-up', if any."
   :group 'mouse
   :type 'symbol
   :set #'mouse-wheel-change-button)
 
 (defcustom mouse-wheel-up-event
   (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-5)
-  "Event used for scrolling up, beside `wheel-up', if any."
+  "Event used for scrolling up, beside `wheel-down', if any."
   :group 'mouse
   :type 'symbol
   :set #'mouse-wheel-change-button)
index 225f8ecf874aa992d8a6b239195e0f4bbf992f9e..5974f07655604dcfb45d0214b4ebd13efb924567 100644 (file)
@@ -1637,14 +1637,16 @@ correctly.")
 
 (defvar flymake--mode-line-counter-map
   (let ((map (make-sparse-keymap)))
+    ;; BEWARE: `mouse-wheel-UP-event' corresponds to `wheel-DOWN' events
+    ;; and vice versa!!
     (define-key map (vector 'mode-line mouse-wheel-down-event)
                 #'flymake--mode-line-counter-scroll-prev)
     (define-key map [mode-line wheel-down]
-                #'flymake--mode-line-counter-scroll-prev)
+                #'flymake--mode-line-counter-scroll-next)
     (define-key map (vector 'mode-line mouse-wheel-up-event)
                 #'flymake--mode-line-counter-scroll-next)
     (define-key map [mode-line wheel-up]
-                #'flymake--mode-line-counter-scroll-next)
+                #'flymake--mode-line-counter-scroll-prev)
     map))
 
 (defun flymake--mode-line-counter-1 (type)