all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 5557@debbugs.gnu.org, larsi@gnus.org, lennart.borgman@gmail.com
Subject: bug#5557: <left-margin> <double-wheel-down> is undefined
Date: Mon, 17 Aug 2020 13:30:37 +0000	[thread overview]
Message-ID: <CADwFkmnjcEUsDZjoooUk6Q9pY9kLToSquMtuHaCde-HsUWWY9Q@mail.gmail.com> (raw)
In-Reply-To: <83pn7un19h.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> I have attached a patch which implements this functionality.
>> Any comments?
>
> I have some:

Please find attached a new patch which should fix the issues you pointed
out.

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Bind-mwheel-scroll-in-more-places.patch --]
[-- Type: text/x-diff, Size: 5078 bytes --]

From c365747c282877b7d975119d2a13cfc69387403c Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Thu, 13 Aug 2020 07:30:03 +0200
Subject: [PATCH] Bind mwheel-scroll in more places

* lisp/mwheel.el (mouse-wheel-mode): Bind unmodified 'mwheel-scroll'
also for fringe, margin, header line and mode line.  (Bug#5557)
(mouse-wheel--create-scroll-keys): New helper function for
'mouse-wheel-mode'.
* test/lisp/mwheel-tests.el: New file.
---
 etc/NEWS                  |  6 ++++++
 lisp/mwheel.el            | 18 ++++++++++++++++--
 test/lisp/mwheel-tests.el | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 test/lisp/mwheel-tests.el

diff --git a/etc/NEWS b/etc/NEWS
index 53e60cdb5c..641671c6e9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -102,6 +102,12 @@ deprecated.  Errors in the Inscript method were corrected.
 ** Rudimentary support for the 'st' terminal emulator.
 Emacs now supports 256 color display on the 'st' terminal emulator.
 
+---
+*** Mouse wheel scrolling less sensitive to positioning.
+When using 'mwheel-mode' (enabled by default), the mouse wheel will
+now scroll also when the mouse cursor is on the fringe, margin, header
+line, and mode line.
+
 \f
 * Editing Changes in Emacs 28.1
 
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 8e2039ba9d..f2dd398859 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -355,6 +355,18 @@ mouse-wheel--remove-bindings
     (when (memq (lookup-key (current-global-map) key) funs)
       (global-unset-key key))))
 
+(defun mouse-wheel--create-scroll-keys (binding event)
+  "Return list of key vectors for BINDING and EVENT.
+BINDING is an element in `mouse-wheel-scroll-amount'.  EVENT is
+an event used for scrolling, e.g. `mouse-wheel-down-event'."
+  (let ((prefixes (list 'left-margin 'right-margin
+                        'left-fringe 'right-fringe
+                        'vertical-scroll-bar 'horizontal-scroll-bar
+                        'mode-line 'header-line)))
+    (cons (vector event)                  ; default case: no prefix.
+          (when (not (consp binding))
+            (mapcar (lambda (prefix) (vector prefix event)) prefixes)))))
+
 (define-minor-mode mouse-wheel-mode
   "Toggle mouse wheel support (Mouse Wheel mode)."
   :init-value t
@@ -379,14 +391,16 @@ mouse-wheel-mode
        ;; Bindings for changing font size.
        ((and (consp binding) (eq (cdr binding) 'text-scale))
         (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event))
+          ;; Add binding.
           (let ((key `[,(list (caar binding) event)]))
             (global-set-key key 'mouse-wheel-text-scale)
             (push key mwheel-installed-text-scale-bindings))))
        ;; Bindings for scrolling.
        (t
         (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
-                             mouse-wheel-right-event mouse-wheel-left-event))
-          (let ((key `[(,@(if (consp binding) (car binding)) ,event)]))
+                             mouse-wheel-left-event mouse-wheel-right-event))
+          (dolist (key (mouse-wheel--create-scroll-keys binding event))
+            ;; Add binding.
             (global-set-key key 'mwheel-scroll)
             (push key mwheel-installed-bindings))))))))
 
diff --git a/test/lisp/mwheel-tests.el b/test/lisp/mwheel-tests.el
new file mode 100644
index 0000000000..cf7fe70dd7
--- /dev/null
+++ b/test/lisp/mwheel-tests.el
@@ -0,0 +1,38 @@
+;;; mwheel-tests.el --- tests for mwheel.el  -*- lexical-binding:t -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'mwheel)
+
+(ert-deftest mwheel-test--create-scroll-keys ()
+  (should (equal (mouse-wheel--create-scroll-keys 10 'mouse-1)
+                 '([mouse-1]
+                   [left-margin mouse-1] [right-margin mouse-1]
+                   [left-fringe mouse-1] [right-fringe mouse-1]
+                   [vertical-scroll-bar mouse-1] [horizontal-scroll-bar mouse-1]
+                   [mode-line mouse-1] [header-line mouse-1])))
+  ;; Don't bind modifiers for fringe, etc.
+  (should (equal (mouse-wheel--create-scroll-keys '((shift) . 1) 'mouse-1)
+                 '([mouse-1])))
+  (should (equal (mouse-wheel--create-scroll-keys '((control) . 9) 'mouse-7)
+                 '([mouse-7]))))
+
+;;; mwheel-tests.el ends here
-- 
2.28.0


  parent reply	other threads:[~2020-08-17 13:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10 13:01 bug#5557: <left-margin> <double-wheel-down> is undefined Lennart Borgman
2019-10-01 15:36 ` Lars Ingebrigtsen
2019-10-01 16:09   ` Eli Zaretskii
2019-10-01 16:19     ` Lars Ingebrigtsen
2019-10-01 16:26       ` Eli Zaretskii
2019-10-01 16:32         ` Lars Ingebrigtsen
2019-10-01 16:36           ` Eli Zaretskii
2019-10-01 17:39             ` Stefan Kangas
2019-10-01 18:31               ` Eli Zaretskii
2019-10-01 18:43                 ` Stefan Kangas
2019-10-01 19:06                   ` Eli Zaretskii
2019-10-02  8:55                     ` martin rudalics
2019-10-03 15:35             ` Lars Ingebrigtsen
2019-10-03 18:11               ` martin rudalics
2020-08-13  5:34                 ` Stefan Kangas
2020-08-13  8:42                   ` Lars Ingebrigtsen
2020-08-13 13:06                   ` Eli Zaretskii
2020-08-14 18:38                     ` Stefan Kangas
2020-08-14 19:13                       ` Eli Zaretskii
2020-08-14 21:34                         ` Stefan Kangas
2020-08-15 17:40                           ` Eli Zaretskii
2020-08-16 13:41                             ` Stefan Kangas
2020-08-16 14:48                               ` Eli Zaretskii
2020-08-16 15:57                                 ` Stefan Kangas
2020-08-17 13:30                     ` Stefan Kangas [this message]
2020-08-22  7:32                       ` Eli Zaretskii
2020-08-22 11:48                         ` Stefan Kangas
2020-08-22 11:59                           ` Eli Zaretskii
2020-08-22 12:11                             ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmnjcEUsDZjoooUk6Q9pY9kLToSquMtuHaCde-HsUWWY9Q@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=5557@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    --cc=lennart.borgman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.