From e5be6c7ae30933a77e81c88a05861dd575286c0c Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 2 Jul 2023 17:49:23 -0400 Subject: [PATCH] Fix flymake mode line scrolling with pixel-scroll-precision-mode When pixel-scroll-precision-mode is enabled, scrolling the mouse wheel will yield wheel-{up,down} events. Flymake now binds the new events in addition to the old mouse-wheel-{up,down}-event. * lisp/progmodes/flymake.el:(flymake--mode-line-counter-scroll-prev) (flymake--mode-line-counter-scroll-next) flymake--mode-line-counter-map): New. (flymake--mode-line-counter): Use new keymap and include 'flymake--diagnostic-type' as a property in the mode-line. (Bug#64428) --- lisp/progmodes/flymake.el | 47 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 3f881ce0cf7..b4c0e4db6ac 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1568,6 +1568,36 @@ correctly.") (defun flymake--mode-line-counters () (when (flymake-running-backends) flymake-mode-line-counter-format)) +(defun flymake--mode-line-counter-scroll-prev (event) + (interactive "e") + (let* ((event-start (event-start event)) + (posn-string (posn-string event-start)) + (type (get-text-property + (cdr posn-string) 'flymake--diagnostic-type (car posn-string)))) + (with-selected-window (posn-window event-start) + (flymake-goto-prev-error 1 (list type) t)))) + +(defun flymake--mode-line-counter-scroll-next (event) + (interactive "e") + (let* ((event-start (event-start event)) + (posn-string (posn-string event-start)) + (type (get-text-property + (cdr posn-string) 'flymake--diagnostic-type (car posn-string)))) + (with-selected-window (posn-window event-start) + (flymake-goto-next-error 1 (list type) t)))) + +(defvar flymake--mode-line-counter-map + (let ((map (make-sparse-keymap))) + (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) + (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) + map)) + (defun flymake--mode-line-counter (type &optional no-space) "Compute number of diagnostics in buffer with TYPE's severity. TYPE is usually keyword `:error', `:warning' or `:note'." @@ -1598,21 +1628,8 @@ TYPE is usually keyword `:error', `:warning' or `:note'." ((eq type :warning) "warnings") ((eq type :note) "notes") (t (format "%s diagnostics" type)))) - keymap - ,(let ((map (make-sparse-keymap))) - (define-key map (vector 'mode-line - mouse-wheel-down-event) - (lambda (event) - (interactive "e") - (with-selected-window (posn-window (event-start event)) - (flymake-goto-prev-error 1 (list type) t)))) - (define-key map (vector 'mode-line - mouse-wheel-up-event) - (lambda (event) - (interactive "e") - (with-selected-window (posn-window (event-start event)) - (flymake-goto-next-error 1 (list type) t)))) - map)))))) + flymake--diagnostic-type ,type + keymap ,flymake--mode-line-counter-map))))) ;;; Per-buffer diagnostic listing -- 2.39.2