bug#43568: Horizontal mouse wheel scrolling

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Juri Linkov-2
As promised in https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01598.html
and mentioned in https://debbugs.gnu.org/28182#58
this patch finally provides horizontal scrolling by shifted mouse wheel:


diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 32fde0dd05..421bebc5f5 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -85,7 +85,7 @@ mouse-wheel-inhibit-click-time
   :type 'number)
 
 (defcustom mouse-wheel-scroll-amount
-  '(5 ((shift) . 1) ((meta) . nil) ((control) . text-scale))
+  '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale))
   "Amount to scroll windows by when spinning the mouse wheel.
 This is an alist mapping the modifier key to the amount to scroll when
 the wheel is moved with the modifier key depressed.
@@ -97,6 +97,9 @@ mouse-wheel-scroll-amount
 a full screen to scroll.  A near full screen is `next-screen-context-lines'
 less than a full screen.
 
+If AMOUNT is the symbol 'hscroll', this means that with MODIFIER,
+the mouse wheel will scroll horizontally instead of vertically.
+
 If AMOUNT is the symbol text-scale, this means that with
 MODIFIER, the mouse wheel will change the face height instead of
 scrolling."
@@ -123,6 +126,7 @@ mouse-wheel-scroll-amount
                     (const :tag "Scroll full screen" :value nil)
                     (integer :tag "Scroll specific # of lines")
                     (float :tag "Scroll fraction of window")
+                    (const :tag "Scroll horizontally" :value hscroll)
                     (const :tag "Change face size" :value text-scale)))))
   :set 'mouse-wheel-change-button
   :version "27.1")
@@ -270,7 +274,11 @@ mwheel-scroll
     (condition-case nil
         (unwind-protect
     (let ((button (mwheel-event-button event)))
-      (cond ((eq button mouse-wheel-down-event)
+              (cond ((and (eq amt 'hscroll) (eq button mouse-wheel-down-event))
+                     (funcall (if mouse-wheel-flip-direction
+                                  mwheel-scroll-left-function
+                                mwheel-scroll-right-function) 1))
+                    ((eq button mouse-wheel-down-event)
                      (condition-case nil (funcall mwheel-scroll-down-function amt)
                        ;; Make sure we do indeed scroll to the beginning of
                        ;; the buffer.
@@ -285,7 +293,11 @@ mwheel-scroll
                           ;; for a reason that escapes me.  This problem seems
                           ;; to only affect scroll-down.  --Stef
                           (set-window-start (selected-window) (point-min))))))
-    ((eq button mouse-wheel-up-event)
+                    ((and (eq amt 'hscroll) (eq button mouse-wheel-up-event))
+                     (funcall (if mouse-wheel-flip-direction
+                                  mwheel-scroll-right-function
+                                mwheel-scroll-left-function) 1))
+                    ((eq button mouse-wheel-up-event)
                      (condition-case nil (funcall mwheel-scroll-up-function amt)
                        ;; Make sure we do indeed scroll to the end of the buffer.
                        (end-of-buffer (while t (funcall mwheel-scroll-up-function)))))
Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Eli Zaretskii
> From: Juri Linkov <[hidden email]>
> Date: Tue, 22 Sep 2020 21:40:49 +0300
>
> As promised in https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01598.html
> and mentioned in https://debbugs.gnu.org/28182#58
> this patch finally provides horizontal scrolling by shifted mouse wheel:

This is a strange use of Shift.  Is this something that other
applications or platforms do?

>  (defcustom mouse-wheel-scroll-amount
> -  '(5 ((shift) . 1) ((meta) . nil) ((control) . text-scale))
> +  '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale))
>    "Amount to scroll windows by when spinning the mouse wheel.
>  This is an alist mapping the modifier key to the amount to scroll when
>  the wheel is moved with the modifier key depressed.
> @@ -97,6 +97,9 @@ mouse-wheel-scroll-amount
>  a full screen to scroll.  A near full screen is `next-screen-context-lines'
>  less than a full screen.
>  
> +If AMOUNT is the symbol 'hscroll', this means that with MODIFIER,
> +the mouse wheel will scroll horizontally instead of vertically.
> +
>  If AMOUNT is the symbol text-scale, this means that with
>  MODIFIER, the mouse wheel will change the face height instead of
>  scrolling."
> @@ -123,6 +126,7 @@ mouse-wheel-scroll-amount
>                      (const :tag "Scroll full screen" :value nil)
>                      (integer :tag "Scroll specific # of lines")
>                      (float :tag "Scroll fraction of window")
> +                    (const :tag "Scroll horizontally" :value hscroll)
>                      (const :tag "Change face size" :value text-scale)))))
>    :set 'mouse-wheel-change-button
>    :version "27.1")

The :version tag should be updated.

This change, if we install it, must be documented in NEWS and in the
manual.

Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Lars Ingebrigtsen
In reply to this post by Juri Linkov-2
Juri Linkov <[hidden email]> writes:

> I sent this patch using the new command `M-x submit-emacs-patch'
> that adds the message header "X-Debbugs-Tags: patch", but I don't see
> the 'patch' tag added in https://debbugs.gnu.org/43568
> so have to add it manually here via [hidden email].

How annoying.  I thought that X-Debbugs-Tags: was the way to add
tags...  but I don't know why I thought that:

  No results found for "x-debbugs-tags".

> Maybe `submit-emacs-patch' should add
>
>   Tags: patch
>
> to the message body?
>
> An additional advantage is that then the user can copy the message body
> to another MUA, e.g. in a web browser, and still "Tags: patch"
> will be preserved, and debbugs will add the 'patch' tag.

I don't think that's something we want to encourage -- there's so many
ways MUAs destroy patches that I think requiring patch senders to do it
from Emacs isn't unwarranted.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Juri Linkov-2
In reply to this post by Eli Zaretskii
tags 43568 fixed
close 43568 28.0.50
quit

>>>    :version "27.1")
>>
>> The :version tag should be updated.

The :version tag was updated now in bug#43380.

>> This change, if we install it, must be documented in NEWS and in the
>> manual.
>
> Ok, will do.

Done.



Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Juri Linkov-2
In reply to this post by Juri Linkov-2
>>  (defcustom mouse-wheel-scroll-amount
>> -  '(5 ((shift) . 1) ((meta) . nil) ((control) . text-scale))
>> +  '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale))
> [...]
>
> If this patch is applied, this bug can be resolved:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43380

Thanks for referring to etc/TODO in bug#43380.

I wonder how relevant here are these TODO items?

  *** "Functional" function-key-map
  It would make it easy to add (and remove) mappings like
  "FOO-mouse-4 -> FOO-scroll-down"

  ** Ability to map a key, including all modified-combinations
  E.g map mouse-4 to wheel-up as well as M-mouse-4 -> M-wheel-up
  M-C-mouse-4 -> M-C-wheel-up, H-S-C-M-s-double-mouse-4 ->
  H-S-C-M-s-double-wheel-up, ...

  **** Automap ctrl-mouse-1 to mouse-3.

Perhaps not much relation to this feature, so this request can be closed.



Reply | Threaded
Open this post in threaded view
|

bug#43568: Horizontal mouse wheel scrolling

Emacs - Bugs mailing list
Juri Linkov <[hidden email]> writes:

>>>  (defcustom mouse-wheel-scroll-amount
>>> -  '(5 ((shift) . 1) ((meta) . nil) ((control) . text-scale))
>>> +  '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale))
>> [...]
>>
>> If this patch is applied, this bug can be resolved:
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43380
>
> Thanks for referring to etc/TODO in bug#43380.

My pleasure


>
> I wonder how relevant here are these TODO items?
>
>   *** "Functional" function-key-map
>   It would make it easy to add (and remove) mappings like
>   "FOO-mouse-4 -> FOO-scroll-down"
>
>   ** Ability to map a key, including all modified-combinations
>   E.g map mouse-4 to wheel-up as well as M-mouse-4 -> M-wheel-up
>   M-C-mouse-4 -> M-C-wheel-up, H-S-C-M-s-double-mouse-4 ->
>   H-S-C-M-s-double-wheel-up, ...
>
>   **** Automap ctrl-mouse-1 to mouse-3.
>
> Perhaps not much relation to this feature, so this request can be closed.

I'm not sure I understand completely what you mean, but just looking at
those mappings, I'd say that seems like a mouthful :)

Theo