GNU bug report logs - #26599
patch for mwheel.el

Previous Next

Package: emacs;

Reported by: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>

Date: Sat, 22 Apr 2017 01:51:02 UTC

Severity: normal

Tags: unreproducible

Done: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>

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 26599 in the body.
You can then email your comments to 26599 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#26599; Package emacs. (Sat, 22 Apr 2017 01:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 22 Apr 2017 01:51:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: bug-gnu-emacs <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp
Subject: patch for mwheel.el
Date: Sat, 22 Apr 2017 10:27:52 +0900 (JST)
To utilize both horizontal and vertical scrolling by touchpad, I
locally turn off auto-hscroll-mode during wheel scrolling using
advice-add.

  (advice-add 'mwheel-scroll :before 'touchpad-mode)

Is it possible to add a line that runs hook on `mwheel.el' to let me
do so without advice-add?

In `(emacs) Coding Standards', to avoid using ‘defadvice’ is
implicitly suggested.  Adding the line lets me implement
`touchpad-mode' which makes swiping touchpad scroll horizontally and
vertically, in cleaner fashion (without any side effects, I think).


diff -u "c:/Users/dream/.emacs.d/site-lisp/mwheel.20170410.el" "c:/Users/dream/.emacs.d/site-lisp/mwheel.el"
--- c:/Users/dream/.emacs.d/site-lisp/mwheel.20170410.el	2017-04-21 09:28:22.949364100 +0900
+++ c:/Users/dream/.emacs.d/site-lisp/mwheel.el	2017-04-21 21:19:46.792800400 +0900
@@ -148,6 +148,12 @@
   :group 'mouse
   :type 'boolean)
 
+(defcustom mwheel-pre-scroll-hook nil
+  "A hook that gets run just before scrolling by wheel."
+  :group 'mouse
+  :type 'hook
+  :version "26.1")
+
 (eval-and-compile
   (if (fboundp 'event-button)
       (fset 'mwheel-event-button 'event-button)
@@ -232,6 +238,7 @@
       ;; When the double-mouse-N comes in, a mouse-N has been executed already,
       ;; So by adding things up we get a squaring up (1, 3, 6, 10, 15, ...).
       (setq amt (* amt (event-click-count event))))
+    (run-hooks 'mwheel-pre-scroll-hook)
     (unwind-protect
 	(let ((button (mwheel-event-button event)))
 	  (cond ((eq button mouse-wheel-down-event)
@@ -320,7 +327,6 @@
   "Enable mouse wheel support."
   (mouse-wheel-mode (if uninstall -1 1)))
 
-
 ;;; For tilt-scroll
 ;;;
 (defcustom mwheel-tilt-scroll-p nil

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Sat, 22 Apr 2017 07:52:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Sat, 22 Apr 2017 10:52:20 +0300
> Date: Sat, 22 Apr 2017 10:27:52 +0900 (JST)
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> Cc: tkk <at> misasa.okayama-u.ac.jp
> 
> Is it possible to add a line that runs hook on `mwheel.el' to let me
> do so without advice-add?

Wouldn't it be better to have a user option which would turn off
auto-hscroll-mode without running any hooks?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Sun, 23 Apr 2017 06:14:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Sun, 23 Apr 2017 15:13:00 +0900 (JST)
>> Is it possible to add a line that runs hook on `mwheel.el' to let me
>> do so without advice-add?
> 
> Wouldn't it be better to have a user option which would turn off
> auto-hscroll-mode without running any hooks?

Yes.  A concern is how to turn auto-hscroll-mode t back.

User decides when to set auto-scroll-mode t again by an event besides
wheel-up, -down, -left, or -down.

My picture is having a minor mode that detects the event and sets
auto-scroll-mode t again.  The minor mode would be described in a file
paired with code that sets auto-scroll-mode nil.

In a case the minor mode is written in a file outside of mwheel.el,
code that sets auto-scroll-mode nil should be on the file too.  In the
scenario hook to invokes the minor mode, is necessary.

In a case the minor mode is written in mwheel.el, hook is not
necessary.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 05:03:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 26 Apr 2017 08:01:47 +0300
> Date: Sun, 23 Apr 2017 15:13:00 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> >> Is it possible to add a line that runs hook on `mwheel.el' to let me
> >> do so without advice-add?
> > 
> > Wouldn't it be better to have a user option which would turn off
> > auto-hscroll-mode without running any hooks?
> 
> Yes.  A concern is how to turn auto-hscroll-mode t back.

maybe I misunderstand something: what I had in mind is turn off
auto-hscroll-mode as part of the mwheel commands, then turn it back on
when the mwheel command did its job.

> User decides when to set auto-scroll-mode t again by an event besides
> wheel-up, -down, -left, or -down.

No, I meant to have it off as long as the mwheel command runs, and
restore it right back immediately afterwards.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 06:09:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Kunihiro Tak <tkk <at> misasa.okayama-u.ac.jp>, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 26 Apr 2017 15:08:42 +0900
>>>> Is it possible to add a line that runs hook on `mwheel.el' to let me
>>>> do so without advice-add?
>>> 
>>> Wouldn't it be better to have a user option which would turn off
>>> auto-hscroll-mode without running any hooks?
>> 
>> Yes.  A concern is how to turn auto-hscroll-mode t back.
> 
> maybe I misunderstand something: what I had in mind is turn off
> auto-hscroll-mode as part of the mwheel commands, then turn it back on
> when the mwheel command did its job.
> 
>> User decides when to set auto-hscroll-mode t again by an event besides
>> wheel-up, -down, -left, or -down.
> 
> No, I meant to have it off as long as the mwheel command runs, and
> restore it right back immediately afterwards.

Let’s consider a buffer consists of very long lines and an empty line.
Point starts from A with auto-hscroll-mode t.

0000..0000 A
0000..0000 I
C          B
D 00..0000 Z

Point reaches to B by scroll up and as soon as auto-hscroll-mode
is set to t, scope will be shifted to point C. Another scrolling
up moves point to D instead of Z.

To visit point Z, timer is required. A minor-mode serves as a long timer.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 10:52:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 26 Apr 2017 13:50:33 +0300
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> Date: Wed, 26 Apr 2017 15:08:42 +0900
> Cc: Kunihiro Tak <tkk <at> misasa.okayama-u.ac.jp>,
>  26599 <at> debbugs.gnu.org
> 
> Let’s consider a buffer consists of very long lines and an empty line.
> Point starts from A with auto-hscroll-mode t.
> 
> 0000..0000 A
> 0000..0000 I
> C          B
> D 00..0000 Z
> 
> Point reaches to B by scroll up and as soon as auto-hscroll-mode
> is set to t, scope will be shifted to point C. Another scrolling
> up moves point to D instead of Z.

I think I'm still missing something, because in my testing, even if
window is hscrolled to show point at C, the next scroll "undoes" that
hscroll to show point at Z.  That's because Emacs tries to keep point
in the same column while scrolling.  So please present a full recipe
which exhibits the problem, including the file to visit and the
commands to invoke.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 12:34:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 26 Apr 2017 21:32:48 +0900 (JST)
>> Let’s consider a buffer consists of very long lines and an empty line.
>> Point starts from A with auto-hscroll-mode t.
>> 
>> 0000..0000 A
>> 0000..0000 I
>> C          B
>> D 00..0000 Z

I did not describe my concern correctly.  Let me rephrase.

Point reaches to B by scrolling up and as soon as auto-hscroll-mode is
set to t, scope will be shifted to point C.

I want to maintain scope with B instead of having scope with C before
another scrolling.

To keep having scope with B, timer is required.  A minor-mode serves
as a long timer.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 15:33:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 26 Apr 2017 18:31:38 +0300
> Date: Wed, 26 Apr 2017 21:32:48 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> >> Let’s consider a buffer consists of very long lines and an empty line.
> >> Point starts from A with auto-hscroll-mode t.
> >> 
> >> 0000..0000 A
> >> 0000..0000 I
> >> C          B
> >> D 00..0000 Z
> 
> I did not describe my concern correctly.  Let me rephrase.
> 
> Point reaches to B by scrolling up and as soon as auto-hscroll-mode is
> set to t, scope will be shifted to point C.
> 
> I want to maintain scope with B instead of having scope with C before
> another scrolling.

If that's what you want, why do you need to turn auto-hscroll-mode
back on?  Just leave it off.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 26 Apr 2017 23:35:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Thu, 27 Apr 2017 08:33:56 +0900 (JST)
>> >> Let’s consider a buffer consists of very long lines and an empty line.
>> >> Point starts from A with auto-hscroll-mode t.
>> >> 
>> >> 0000..0000 A
>> >> 0000..0000 I
>> >> C          B
>> >> D 00..0000 Z
>> 
>> Point reaches to B by scrolling up and as soon as auto-hscroll-mode is
>> set to t, scope will be shifted to point C.
>> 
>> I want to maintain scope with B instead of having scope with C before
>> another scrolling.
> 
> If that's what you want, why do you need to turn auto-hscroll-mode
> back on?  Just leave it off.

Yes.  However, after wheel cruise with auto-hscroll-mode nil, I want
to start editing.

Sooner or later I want to use C-a to go outside of current scope.
This is the timing when I want to set auto-hscroll-mode nil.  An event
from me should do it.  The event must be some events besides
<wheel-up>, <wheel-down>, <wheel-right>, or <wheel-left>, and can be
C-a or <down-mouse-1>.

My picture is having a minor mode with keymap <down-mouse-1>
configured to set auto-hscroll-mode t.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Thu, 27 Apr 2017 02:38:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Thu, 27 Apr 2017 05:36:19 +0300
> Date: Thu, 27 Apr 2017 08:33:56 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> >> I want to maintain scope with B instead of having scope with C before
> >> another scrolling.
> > 
> > If that's what you want, why do you need to turn auto-hscroll-mode
> > back on?  Just leave it off.
> 
> Yes.  However, after wheel cruise with auto-hscroll-mode nil, I want
> to start editing.
> 
> Sooner or later I want to use C-a to go outside of current scope.
> This is the timing when I want to set auto-hscroll-mode nil.

You have the horizontal-scroll commands to do that, right?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Thu, 27 Apr 2017 05:28:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Thu, 27 Apr 2017 14:27:31 +0900 (JST)
>> >> I want to maintain scope with B instead of having scope with C before
>> >> another scrolling.
>> > 
>> > If that's what you want, why do you need to turn auto-hscroll-mode
>> > back on?  Just leave it off.
>> 
>> Yes.  However, after wheel cruise with auto-hscroll-mode nil, I want
>> to start editing.
>> 
>> Sooner or later I want to use C-a to go outside of current scope.
>> This is the timing when I want to set auto-hscroll-mode t.
> 
> You have the horizontal-scroll commands to do that, right?

Yes.

I consider two devices to scroll, that are keyboard and mouse.

Keyboard is the primary scroll device.  Thus I want to turn
auto-hscroll-mode t by default.

Occasionally I want to use mouse as scroll device.  When I use mouse,
I want to set turn auto-hscroll-mode nil, especially after
implementation of <wheel-right> and <wheel-left>.

When I come back to keyboard, I want to set auto-hscroll-mode t again.

| device   | auto-hscroll-mode |
|----------+-------------------|
| keyboard | t                 |
| mouse    | nil               |
| keyboard | t                 |
| mouse    | nil               |
| keyboard | t                 |

To do so, I want to call minor-mode on `mwheel-scroll'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Thu, 27 Apr 2017 14:26:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Thu, 27 Apr 2017 17:25:06 +0300
> Date: Thu, 27 Apr 2017 14:27:31 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> > You have the horizontal-scroll commands to do that, right?
> 
> Yes.
> 
> I consider two devices to scroll, that are keyboard and mouse.
> 
> Keyboard is the primary scroll device.  Thus I want to turn
> auto-hscroll-mode t by default.
> 
> Occasionally I want to use mouse as scroll device.  When I use mouse,
> I want to set turn auto-hscroll-mode nil, especially after
> implementation of <wheel-right> and <wheel-left>.
> 
> When I come back to keyboard, I want to set auto-hscroll-mode t again.

This looks like a very specialized use case, so I'm not sure we need a
solution for it in Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Thu, 27 Apr 2017 23:17:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Fri, 28 Apr 2017 08:16:00 +0900 (JST)
>> > You have the horizontal-scroll commands to do that, right?
>> 
>> Yes.
>> 
>> I consider two devices to scroll, that are keyboard and mouse.
>> 
>> Keyboard is the primary scroll device.  Thus I want to turn
>> auto-hscroll-mode t by default.
>> 
>> Occasionally I want to use mouse as scroll device.  When I use mouse,
>> I want to set turn auto-hscroll-mode nil, especially after
>> implementation of <wheel-right> and <wheel-left>.
>> 
>> When I come back to keyboard, I want to set auto-hscroll-mode t again.
> 
> This looks like a very specialized use case, so I'm not sure we need a
> solution for it in Emacs.

I see how you see.

How I described, is similar to how spreadsheet program reacts.  It
lets user scroll both by <wheel-left> and <left>.

I very often edit a buffer with long and short line (for example,
LaTeX table), using mouse and keyboard.  However, as you infer, this
can be already very special.

Isn't my description convincing enough to install the line that
invokes the minor mode `touchpad-disable--auto-hscroll-mode'?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Fri, 28 Apr 2017 06:49:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Fri, 28 Apr 2017 09:47:43 +0300
> Date: Fri, 28 Apr 2017 08:16:00 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> >> Keyboard is the primary scroll device.  Thus I want to turn
> >> auto-hscroll-mode t by default.
> >> 
> >> Occasionally I want to use mouse as scroll device.  When I use mouse,
> >> I want to set turn auto-hscroll-mode nil, especially after
> >> implementation of <wheel-right> and <wheel-left>.
> >> 
> >> When I come back to keyboard, I want to set auto-hscroll-mode t again.
> > 
> > This looks like a very specialized use case, so I'm not sure we need a
> > solution for it in Emacs.
> 
> I see how you see.
> 
> How I described, is similar to how spreadsheet program reacts.  It
> lets user scroll both by <wheel-left> and <left>.
> 
> I very often edit a buffer with long and short line (for example,
> LaTeX table), using mouse and keyboard.  However, as you infer, this
> can be already very special.

What makes this special is that you want Emacs to work differently
depending on the input device.  Emacs normally makes a significant
effort in the other direction: to produce the same behavior no matter
where input came from.

I'm not sure we want to have such unusual behavior as part of Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Fri, 28 Apr 2017 09:14:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: eliz <at> gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Fri, 28 Apr 2017 18:12:50 +0900 (JST)
[Message part 1 (text/plain, inline)]
>> >> Keyboard is the primary scroll device.  Thus I want to turn
>> >> auto-hscroll-mode t by default.
>> >> 
>> >> Occasionally I want to use mouse as scroll device.  When I use mouse,
>> >> I want to set turn auto-hscroll-mode nil, especially after
>> >> implementation of <wheel-right> and <wheel-left>.
>> >> 
>> >> When I come back to keyboard, I want to set auto-hscroll-mode t again.
>> > 
>> > This looks like a very specialized use case, so I'm not sure we need a
>> > solution for it in Emacs.
>> 
>> I see how you see.
>> 
>> How I described, is similar to how spreadsheet program reacts.  It
>> lets user scroll both by <wheel-left> and <left>.
>> 
>> I very often edit a buffer with long and short line (for example,
>> LaTeX table), using mouse and keyboard.  However, as you infer, this
>> can be already very special.
> 
> What makes this special is that you want Emacs to work differently
> depending on the input device.  Emacs normally makes a significant
> effort in the other direction: to produce the same behavior no matter
> where input came from.
> 
> I'm not sure we want to have such unusual behavior as part of Emacs.

Can you take a look minor-mode that I want to invoke by hook?  I still
think this is potentially useful to mouse-loving cloud using
<wheel-left> and <wheel-right>.

[touchpad.el (text/plain, inline)]
;;; touchpad.el --- Scroll two dimensionally by touchpad

;; Copyright (C) 2017 Tak Kunihiro
;; Author: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
;; Maintainer: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
;; URL: http://dream.misasa.okayama-u.ac.jp
;; Package-Requires: ((emacs "26.1"))
;; Version: 1.0.0
;; Package-Version: 20170427.1515
;; Keywords: mouse, scroll

;;; This file is NOT part of GNU Emacs

;;; License

;; This program 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, or (at your option)
;; any later version.

;; This program 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 this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.

;;; Commentary:

;; To interactively toggle the mode:
;;
;;   M-x touchpad-mode
;;
;; To make the mode permanent, add the following lines to your init
;; file.
;;
;;   (require 'touchpad)
;;   (touchpad-mode 1)
;;
;; This package offers a global minor mode which makes swiping
;; touchpad scroll smoothly.  This package disables
;; `auto-hscroll-mode' during scroll because of following two aspects.

;; (1) It should be off during vertical scroll.  Let’s consider a
;;     buffer is with short and long alternative lines and when point
;;     is at the end of long line, at the top of current window.
;;     After `scroll-up 1', point jumps to the end of the next short
;;     line and you see scope shifts suddenly leftward.  This behavior
;;     is sometimes unexpected one.

;; (2) It should be off during horizontal scroll.  During horizontal
;;     scroll, you may scroll a little in vertical direction without
;;     intention.  The horizontal scroll should be tolerance against
;;     such perturbation.  The source of concern is same as (1).

;; After scroll, you want to set `auto-hscroll-mode' back again
;; otherwise too inconvenient for further edition.  Approach of this
;; package is to turn on another minor-mode `touchpad--2d-mode' with
;; `auto-hscroll-mode' nil at the beginning of `mwheel-scroll'.  The
;; minor mode is turned off upon any key inputs that move point.

;;; Change Log:

;; 20170409.1204
;;  - (setq scroll-conservatively 100) on minor mode may work as backup

;;; Todo:
;;  - Release as a package

(require 'mwheel)

;;; Code:
(defvar touchpad--cursor-type cursor-type
  "Cursor used by user.  This variable is used internally to
  restore original `cursor-type'.")

(define-minor-mode touchpad-mode
  "A minor mode to scroll text two dimensionally.  With a prefix argument ARG,
enable Touchpad Mode if ARG is positive, and disable it
otherwise.  If called from Lisp, enable Touchpad Mode if ARG is
omitted or nil."
  :init-value nil
  :group 'scrolling
  :global t

  (if touchpad-mode
      (progn
        (advice-add 'mwheel-scroll :before 'touchpad-enable--2d-mode)
        ;; (add-hook 'mwheel-pre-scroll-hook 'touchpad-enable--2d-mode)
        (setq mwheel-tilt-scroll-p t))
    (advice-remove 'mwheel-scroll #'touchpad-enable--2d-mode)
    ;; (remove-hook 'mwheel-pre-scroll-hook 'touchpad-enable--2d-mode)
    (dolist (var '(mwheel-tilt-scroll-p))
      (custom-reevaluate-setting var))))

;; (defun touchpad-enable--2d-mode ()
;;   "Enable minor mode `touchpad--2d-mode' to disable
;; `auto-hscroll-mode'.  This is supposed to be called before actual
;; scrolling."
;;   (let ((buffer (window-buffer (mwheel-event-window last-input-event))))
;;     (with-current-buffer buffer
;;       (touchpad--2d-mode 1)))) ; turn on minor-mode

(defun touchpad-enable--2d-mode (func &rest args)
  "Enable minor mode `touchpad--2d-mode' to disable
`auto-hscroll-mode'.  This is supposed to be adviced before
`mwheel-scroll'."
  (let ((buffer (window-buffer (mwheel-event-window last-input-event))))
    (with-current-buffer buffer
      (touchpad--2d-mode 1)))) ; turn on minor-mode

(defun touchpad-disable--2d-mode ()
  "Disable minor mode `touchpad--2d-mode' to enable
`auto-hscroll-mode' back.  Then invoke command that is bound to
the original key."
  (interactive)
  (touchpad--2d-mode 0) ; turn off minor-mode
  (call-interactively (key-binding (this-command-keys))))

(define-minor-mode touchpad--2d-mode
  "A minor-mode with `auto-hscroll-mode' off.  This minor mode is used
internally."
  :init-value nil
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map [remap keyboard-quit] 'touchpad-disable--2d-mode)
            (define-key map [remap mouse-set-point] 'touchpad-disable--2d-mode)
            (define-key map [remap right-char] 'touchpad-disable--2d-mode)
            (define-key map [remap forward-char] 'touchpad-disable--2d-mode)
            (define-key map [remap forward-word] 'touchpad-disable--2d-mode)
            (define-key map [remap forward-sentence] 'touchpad-disable--2d-mode)
            (define-key map [remap forward-paragraph] 'touchpad-disable--2d-mode)
            (define-key map [remap forward-page] 'touchpad-disable--2d-mode)
            (define-key map [remap left-char] 'touchpad-disable--2d-mode)
            (define-key map [remap backward-char] 'touchpad-disable--2d-mode)
            (define-key map [remap backward-word] 'touchpad-disable--2d-mode)
            (define-key map [remap backward-sentence] 'touchpad-disable--2d-mode)
            (define-key map [remap backward-paragraph] 'touchpad-disable--2d-mode)
            (define-key map [remap backward-page] 'touchpad-disable--2d-mode)
            (define-key map [remap move-beginning-of-line] 'touchpad-disable--2d-mode)
            (define-key map [remap move-end-of-line] 'touchpad-disable--2d-mode)
            (define-key map [remap next-line] 'touchpad-disable--2d-mode)
            (define-key map [remap next-error] 'touchpad-disable--2d-mode)
            (define-key map [remap scroll-up-command] 'touchpad-disable--2d-mode)
            (define-key map [remap previous-line] 'touchpad-disable--2d-mode)
            (define-key map [remap previous-error] 'touchpad-disable--2d-mode)
            (define-key map [remap scroll-down-command] 'touchpad-disable--2d-mode)
            (define-key map [remap beginning-of-defun] 'touchpad-disable--2d-mode)
            (define-key map [remap beginning-of-buffer] 'touchpad-disable--2d-mode)
            (define-key map [remap end-of-defun] 'touchpad-disable--2d-mode)
            (define-key map [remap end-of-buffer] 'touchpad-disable--2d-mode)
            (define-key map [remap goto-char] 'touchpad-disable--2d-mode)
            (define-key map [remap goto-line] 'touchpad-disable--2d-mode)
            (define-key map [remap move-to-column] 'touchpad-disable--2d-mode)
            ;; list as much as think of ... or map all but
            ;; (where-is-internal 'mwheel-scroll)?
            map)
  :group 'scrolling

  (if touchpad--2d-mode
      (progn
        (setq-local auto-hscroll-mode nil)
        (setq-local cursor-type 'hollow))
    (setq-local auto-hscroll-mode t)
    (setq-local cursor-type touchpad--cursor-type)))

(provide 'touchpad)
;;; touchpad.el ends here

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Fri, 19 May 2017 08:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Fri, 19 May 2017 11:55:35 +0300
> Date: Fri, 28 Apr 2017 18:12:50 +0900 (JST)
> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
> 
> > What makes this special is that you want Emacs to work differently
> > depending on the input device.  Emacs normally makes a significant
> > effort in the other direction: to produce the same behavior no matter
> > where input came from.
> > 
> > I'm not sure we want to have such unusual behavior as part of Emacs.
> 
> Can you take a look minor-mode that I want to invoke by hook?  I still
> think this is potentially useful to mouse-loving cloud using
> <wheel-left> and <wheel-right>.

I'm okay with adding this to ELPA.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Mon, 24 Jun 2019 16:39:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Mon, 24 Jun 2019 18:38:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Fri, 28 Apr 2017 18:12:50 +0900 (JST)
>> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
>> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
>> 
>> > What makes this special is that you want Emacs to work differently
>> > depending on the input device.  Emacs normally makes a significant
>> > effort in the other direction: to produce the same behavior no matter
>> > where input came from.
>> > 
>> > I'm not sure we want to have such unusual behavior as part of Emacs.
>> 
>> Can you take a look minor-mode that I want to invoke by hook?  I still
>> think this is potentially useful to mouse-loving cloud using
>> <wheel-left> and <wheel-right>.
>
> I'm okay with adding this to ELPA.

But for this minor mode to work, I think mwheel-pre-scroll-hook had to
be implemented, if I understood correctly?

This is two years old, though, so I'm not sure any of this is still an
issue...

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Mon, 20 Jan 2020 20:07:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>,
 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Mon, 20 Jan 2020 21:06:27 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Date: Fri, 28 Apr 2017 18:12:50 +0900 (JST)
>>> Cc: 26599 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
>>> From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
>>> 
>>> > What makes this special is that you want Emacs to work differently
>>> > depending on the input device.  Emacs normally makes a significant
>>> > effort in the other direction: to produce the same behavior no matter
>>> > where input came from.
>>> > 
>>> > I'm not sure we want to have such unusual behavior as part of Emacs.
>>> 
>>> Can you take a look minor-mode that I want to invoke by hook?  I still
>>> think this is potentially useful to mouse-loving cloud using
>>> <wheel-left> and <wheel-right>.
>>
>> I'm okay with adding this to ELPA.
>
> But for this minor mode to work, I think mwheel-pre-scroll-hook had to
> be implemented, if I understood correctly?
>
> This is two years old, though, so I'm not sure any of this is still an
> issue...

That was over 7 months ago.  Is there still any interest in adding
this package to ELPA?  Thanks.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Mon, 20 Jan 2020 23:13:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>, 26599 <at> debbugs.gnu.org
Subject: Re: bug#26599: patch for mwheel.el
Date: Tue, 21 Jan 2020 00:47:15 +0200
> That was over 7 months ago.  Is there still any interest in adding
> this package to ELPA?  Thanks.

It seems this is about the built-in package mwheel.el where
mouse-wheel-scroll-amount could support the option 'hscroll'
like proposed in bug#28182.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Tue, 21 Jan 2020 07:18:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
 26599 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#26599: patch for mwheel.el
Date: Tue, 21 Jan 2020 16:17:21 +0900
I wanted to set auto-hscroll-mode to nil, only during 2D scroll
(hscroll-and-vscroll mixed one) using mouse.  Since 2D scroll is
unusable when auto-hscroll-mode is t, I thought what I wanted was
implicit voice of all mouse lovers...apparently was not.

I'm good without the hook nor ELPA.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Tue, 21 Jan 2020 09:47:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 26599 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#26599: patch for mwheel.el
Date: Tue, 21 Jan 2020 10:46:36 +0100
Hi Tak,

Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp> writes:

> I wanted to set auto-hscroll-mode to nil, only during 2D scroll
> (hscroll-and-vscroll mixed one) using mouse.  Since 2D scroll is
> unusable when auto-hscroll-mode is t, I thought what I wanted was
> implicit voice of all mouse lovers...apparently was not.
>
> I'm good without the hook nor ELPA.

Thank you for your reply.

Please don't interpret the long response times here as a sign that
your package is not welcome.  I think we are all in favour of
improving mouse and/or trackpad support in Emacs, something which
would clearly benefit a significant subset of users.  Unfortunately,
we often have the problem that we lack the necessary resources to
follow up on all bug reports in a timely manner.

I think we should try to make progress here, and get your package into
ELPA, in order that people can start using it.

To move this ahead, if I understand things correctly, there is only
one important question left to resolve, namely that of a hook in
mwheel.el.  Reading your code, I see that you have two commented out
lines running the hook `mwheel-pre-scroll-hook'.  Could you please
provide a patch or instructions for where to add this hook in
mwheel.el?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Wed, 22 Jan 2020 05:47:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: 26599 <at> debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
 Stefan Kangas <stefan <at> marxist.se>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#26599: patch for mwheel.el
Date: Wed, 22 Jan 2020 14:46:20 +0900
Dear Stefan,

Before discussions about hook, I want to insist again that on 2D mouse
browsing and on keyboard editing, auto-hscroll-mode should be set to
nil and non-nil, respectively.  Otherwise 2D scroll by mwheel is not
helpful.

Eli inferred Emacs does not prefer to respond differently to different
input devices.  That makes sense too.

How do you think about user experience on 2D scrolling with (setq
mouse-wheel-tilt-scroll t) or typing with (setq
mouse-wheel-tilt-scroll nil)?

 emacs -Q
 M-x eww
 www.gnu.org/gnu/gnu.html
 M-: (set-window-hscroll (selected-window) 50)
 M-: (setq mouse-wheel-tilt-scroll t)
 2D scrolling by mwheel --> Soon scope moves to left.
 M-: (setq auto-hscroll-mode nil)
 2D scrolling by mwheel ... good
 Move point using keyboard ... Scope never changes.

Tak





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Fri, 13 Mar 2020 23:44:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <homeros.misasa <at> gmail.com>
To: 26599 <at> debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, tkk <at> misasa.okayama-u.ac.jp,
 Stefan Kangas <stefan <at> marxist.se>, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#26599: patch for mwheel.el
Date: Sat, 14 Mar 2020 08:43:33 +0900
I cannot reproduce the problem with `emacs -Q`.  I found that this is my
local problem; thus no one would be bothered with two dimensional
scrolling.  Two dimensional scrolling is good.  I apologize to sustain
such a long noise.  No hook and no ELPA are necessary.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26599; Package emacs. (Fri, 13 Mar 2020 23:54:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <homeros.misasa <at> gmail.com>
To: 26599 <at> debbugs.gnu.org
Cc: tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#26599: patch for mwheel.el
Date: Sat, 14 Mar 2020 08:52:57 +0900
tags 26599 unreproducible
close 26599




Added tag(s) unreproducible. Request was from Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp> to control <at> debbugs.gnu.org. (Sat, 14 Mar 2020 03:30:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 26599 <at> debbugs.gnu.org and Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp> Request was from Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp> to control <at> debbugs.gnu.org. (Sat, 14 Mar 2020 03:30:02 GMT) Full text and rfc822 format available.

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

This bug report was last modified 4 years and 15 days ago.

Previous Next


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