unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43568: Horizontal mouse wheel scrolling
@ 2020-09-22 18:40 Juri Linkov
  2020-09-22 18:51 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Juri Linkov @ 2020-09-22 18:40 UTC (permalink / raw)
  To: 43568

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

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mwheel-hscroll.patch --]
[-- Type: text/patch, Size: 3004 bytes --]

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:40 bug#43568: Horizontal mouse wheel scrolling Juri Linkov
@ 2020-09-22 18:51 ` Eli Zaretskii
  2020-09-22 19:09   ` Juri Linkov
  2020-09-22 18:55 ` Juri Linkov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2020-09-22 18:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 43568

> From: Juri Linkov <juri@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.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:40 bug#43568: Horizontal mouse wheel scrolling Juri Linkov
  2020-09-22 18:51 ` Eli Zaretskii
@ 2020-09-22 18:55 ` Juri Linkov
  2020-09-23 13:52   ` Lars Ingebrigtsen
  2020-09-22 20:02 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-10-31 20:30 ` Juri Linkov
  3 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-09-22 18:55 UTC (permalink / raw)
  To: 43568

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@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.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:51 ` Eli Zaretskii
@ 2020-09-22 19:09   ` Juri Linkov
  2020-09-24 19:25     ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-09-22 19:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 43568

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:40 bug#43568: Horizontal mouse wheel scrolling Juri Linkov
  2020-09-22 18:51 ` Eli Zaretskii
  2020-09-22 18:55 ` Juri Linkov
@ 2020-09-22 20:02 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-09-24 19:27   ` Juri Linkov
  2020-10-31 20:30 ` Juri Linkov
  3 siblings, 1 reply; 11+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-09-22 20:02 UTC (permalink / raw)
  To: Juri Linkov, 43568

Juri Linkov <juri@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








^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:55 ` Juri Linkov
@ 2020-09-23 13:52   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-23 13:52 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 43568

Juri Linkov <juri@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@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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 19:09   ` Juri Linkov
@ 2020-09-24 19:25     ` Juri Linkov
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2020-09-24 19:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 43568

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.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 20:02 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-09-24 19:27   ` Juri Linkov
  2020-09-24 20:07     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-09-24 19:27 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: 43568

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-24 19:27   ` Juri Linkov
@ 2020-09-24 20:07     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 11+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-09-24 20:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 43568

Juri Linkov <juri@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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-09-22 18:40 bug#43568: Horizontal mouse wheel scrolling Juri Linkov
                   ` (2 preceding siblings ...)
  2020-09-22 20:02 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-10-31 20:30 ` Juri Linkov
  2020-11-03 19:06   ` Juri Linkov
  3 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-10-31 20:30 UTC (permalink / raw)
  To: 43568

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mouse-wheel-scroll-horizontal-step.patch --]
[-- Type: text/x-diff, Size: 4338 bytes --]

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.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#43568: Horizontal mouse wheel scrolling
  2020-10-31 20:30 ` Juri Linkov
@ 2020-11-03 19:06   ` Juri Linkov
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2020-11-03 19:06 UTC (permalink / raw)
  To: 43568

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-03 19:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22 18:40 bug#43568: Horizontal mouse wheel scrolling Juri Linkov
2020-09-22 18:51 ` Eli Zaretskii
2020-09-22 19:09   ` Juri Linkov
2020-09-24 19:25     ` Juri Linkov
2020-09-22 18:55 ` Juri Linkov
2020-09-23 13:52   ` Lars Ingebrigtsen
2020-09-22 20:02 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-24 19:27   ` Juri Linkov
2020-09-24 20:07     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-10-31 20:30 ` Juri Linkov
2020-11-03 19:06   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).