summaryrefslogtreecommitdiff
path: root/lisp/mwheel.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2020-09-24 22:25:03 +0300
committerJuri Linkov <juri@linkov.net>2020-09-24 22:25:03 +0300
commit1e7f6365766db188e8cbcee5a9cdad8e2b4f5849 (patch)
tree7a477d311ce63339e98a2415b18ede721da8d3c4 /lisp/mwheel.el
parent89dd8cd215148da4c6dffc15dc6c35df5122247b (diff)
downloademacs-1e7f6365766db188e8cbcee5a9cdad8e2b4f5849.tar.gz
Horizontal scrolling for mouse wheel with Shift modifier (bug#43568)
* lisp/mwheel.el (mouse-wheel-scroll-amount): Change 'shift' default value from 5 to 'hscroll'. Add new option "Scroll horizontally" for 'hscroll'. (mwheel-scroll): Handle value 'hscroll' and call mwheel-scroll-left-function or mwheel-scroll-right-function. * doc/emacs/frames.texi (Mouse Commands): Update for horizontal scrolling with Shift modifier.
Diffstat (limited to 'lisp/mwheel.el')
-rw-r--r--lisp/mwheel.el18
1 files changed, 15 insertions, 3 deletions
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 0100b8de81e..c6a7391df1a 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -85,7 +85,7 @@ set to the event sent when clicking on the mouse wheel button."
:type 'number)
(defcustom mouse-wheel-scroll-amount
- '(1 ((shift) . 5) ((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 @@ screen. It can also be a floating point number, specifying the fraction of
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 @@ scrolling."
(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 "28.1")
@@ -270,7 +274,11 @@ non-Windows systems."
(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 @@ non-Windows systems."
;; 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)))))