GNU bug report logs - #43568
Horizontal mouse wheel scrolling

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 22 Sep 2020 18:44:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43568 in the body.
You can then email your comments to 43568 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 22 Sep 2020 18:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 22 Sep 2020 18:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Horizontal mouse wheel scrolling
Date: Tue, 22 Sep 2020 21:40:49 +0300
[Message part 1 (text/plain, inline)]
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:

[mwheel-hscroll.patch (text/patch, inline)]
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)))))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 22 Sep 2020 18:52:01 GMT) Full text and rfc822 format available.

Message #8 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Tue, 22 Sep 2020 21:51:49 +0300
> From: Juri Linkov <juri <at> linkov.net>
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 22 Sep 2020 19:00:01 GMT) Full text and rfc822 format available.

Message #11 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Tue, 22 Sep 2020 21:55:22 +0300
tags 43568 + patch
quit

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 control <at> debbugs.gnu.org.

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.




Added tag(s) patch. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 22 Sep 2020 19:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 22 Sep 2020 19:11:02 GMT) Full text and rfc822 format available.

Message #16 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Tue, 22 Sep 2020 22:09:43 +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?

Yes, this is what other applications do.
I can't find an application that doesn't support
horizontal scrolling with Shift.

>>    :version "27.1")
>
> The :version tag should be updated.
>
> This change, if we install it, must be documented in NEWS and in the
> manual.

Ok, will do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 22 Sep 2020 20:03:02 GMT) Full text and rfc822 format available.

Message #19 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Juri Linkov <juri <at> linkov.net>, 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Tue, 22 Sep 2020 22:02:28 +0200
Juri Linkov <juri <at> linkov.net> writes:

> 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:

[...]
>  
>  (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

All the best,
Theodor Thornhill







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Wed, 23 Sep 2020 13:53:02 GMT) Full text and rfc822 format available.

Message #22 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Wed, 23 Sep 2020 15:52:14 +0200
Juri Linkov <juri <at> linkov.net> 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 control <at> debbugs.gnu.org.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Thu, 24 Sep 2020 19:29:01 GMT) Full text and rfc822 format available.

Message #25 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Thu, 24 Sep 2020 22:27:46 +0300
>>  (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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Thu, 24 Sep 2020 19:29:02 GMT) Full text and rfc822 format available.

Message #28 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Thu, 24 Sep 2020 22:25:29 +0300
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.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Thu, 24 Sep 2020 19:29:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 43568 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Thu, 24 Sep 2020 19:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Thu, 24 Sep 2020 20:08:02 GMT) Full text and rfc822 format available.

Message #35 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Juri Linkov <juri <at> linkov.net>
Cc: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Thu, 24 Sep 2020 22:07:35 +0200
Juri Linkov <juri <at> linkov.net> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Oct 2020 11:24:06 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sat, 31 Oct 2020 20:24:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Sat, 31 Oct 2020 20:52:02 GMT) Full text and rfc822 format available.

Message #42 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Sat, 31 Oct 2020 22:30:03 +0200
[Message part 1 (text/plain, inline)]
Currently the mouse-wheel horizontal scrolling step is hard-coded to the
constant 1.  It's very inconvenient to scroll large amount of text
horizontally by small increments.  For example, the horizontal step is
hard-coded to 3 in Firefox, and to 5 in Chrome.

But since Emacs is much more powerful than web browsers in regard to
customization, the following patch adds a new user option to define the
default step, and also allows the user to change the step dynamically by
using a numeric prefix arg before starting to scroll, e.g. typing 'M-8'
before scrolling will set the scroll step to 8.

[mouse-wheel-scroll-horizontal-step.patch (text/x-diff, inline)]
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 1a44d8dc62..6b070d932a 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -214,7 +214,10 @@ Mouse Commands
 supports increasing or decreasing the height of the default face, by
 default bound to scrolling with the @key{Ctrl} modifier.
 
-Emacs also supports horizontal scrolling with the @key{Shift} modifier.
+Emacs also supports horizontal scrolling with the @key{Shift}
+modifier.  Typing a numeric prefix arg (e.g. @kbd{C-u 5}) before
+starting horizontal scrolling changes its step value defined
+by the user option @code{mouse-wheel-scroll-horizontal-step}.
 
 @vindex mouse-wheel-tilt-scroll
 @vindex mouse-wheel-flip-direction
diff --git a/etc/NEWS b/etc/NEWS
index 5a646d2bb9..74959bb2de 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -153,7 +156,9 @@ displays.)
 
 +++
 ** Mouse wheel scrolling with Shift modifier now scrolls horizontally.
-This works in text buffers and over images.
+This works in text buffers and over images.  Typing a numeric prefix arg
+(e.g. 'C-u 5') before starting horizontal scrolling changes its step value.
+Its value is saved in the user option 'mouse-wheel-scroll-horizontal-step'.
 
 ---
 ** The default value of 'frame-title-format' and 'icon-title-format' has changed.
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index c6a7391df1..a49a4254d1 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -146,6 +146,14 @@ mouse-wheel-follow-mouse
   :group 'mouse
   :type 'boolean)
 
+(defcustom mouse-wheel-scroll-horizontal-step 1
+  "Amount to scroll windows horizontally.
+Its value can be changed dynamically by using a numeric prefix argument
+before starting horizontal scrolling."
+  :group 'mouse
+  :type 'number
+  :version "28.1")
+
 ;;; For tilt-scroll
 ;;;
 (defcustom mouse-wheel-tilt-scroll nil
@@ -243,11 +251,14 @@ mouse-wheel--get-scroll-window
                frame nil t)))))
       (mwheel-event-window event)))
 
-(defun mwheel-scroll (event)
+(defun mwheel-scroll (event &optional arg)
   "Scroll up or down according to the EVENT.
 This should be bound only to mouse buttons 4, 5, 6, and 7 on
-non-Windows systems."
-  (interactive (list last-input-event))
+non-Windows systems.
+
+An optional prefix ARG can be used to change the step of horizontal
+scrolling.  The arg numeric value can be typed before starting to scroll."
+  (interactive (list last-input-event current-prefix-arg))
   (let* ((selected-window (selected-window))
          (scroll-window (mouse-wheel--get-scroll-window event))
 	 (old-point
@@ -275,9 +286,12 @@ mwheel-scroll
         (unwind-protect
 	    (let ((button (mwheel-event-button event)))
               (cond ((and (eq amt 'hscroll) (eq button mouse-wheel-down-event))
+                     (when (and (natnump arg) (> arg 0))
+                       (setq mouse-wheel-scroll-horizontal-step arg))
                      (funcall (if mouse-wheel-flip-direction
                                   mwheel-scroll-left-function
-                                mwheel-scroll-right-function) 1))
+                                mwheel-scroll-right-function)
+                              mouse-wheel-scroll-horizontal-step))
                     ((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
@@ -294,9 +308,12 @@ mwheel-scroll
                           ;; to only affect scroll-down.  --Stef
                           (set-window-start (selected-window) (point-min))))))
                     ((and (eq amt 'hscroll) (eq button mouse-wheel-up-event))
+                     (when (and (natnump arg) (> arg 0))
+                       (setq mouse-wheel-scroll-horizontal-step arg))
                      (funcall (if mouse-wheel-flip-direction
                                   mwheel-scroll-right-function
-                                mwheel-scroll-left-function) 1))
+                                mwheel-scroll-left-function)
+                              mouse-wheel-scroll-horizontal-step))
                     ((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.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43568; Package emacs. (Tue, 03 Nov 2020 19:11:02 GMT) Full text and rfc822 format available.

Message #45 received at 43568 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 43568 <at> debbugs.gnu.org
Subject: Re: bug#43568: Horizontal mouse wheel scrolling
Date: Tue, 03 Nov 2020 21:06:33 +0200
> Currently the mouse-wheel horizontal scrolling step is hard-coded to the
> constant 1.  It's very inconvenient to scroll large amount of text
> horizontally by small increments.  For example, the horizontal step is
> hard-coded to 3 in Firefox, and to 5 in Chrome.
>
> But since Emacs is much more powerful than web browsers in regard to
> customization, the following patch adds a new user option to define the
> default step, and also allows the user to change the step dynamically by
> using a numeric prefix arg before starting to scroll, e.g. typing 'M-8'
> before scrolling will set the scroll step to 8.

Pushed now.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 02 Dec 2020 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 143 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.