1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-08 20:58:58 +00:00

Scroll right and left using wheel-right and wheel-left.

These changes also make use of touchpad and trackpad (Bug#26347).

* doc/emacs/frames.texi (Mouse Commands): Document horizontal
scrolling using the mouse wheel.

* lisp/mwheel.el (mwheel-scroll): Respond to wheel-right and wheel-left.
(mwheel-tilt-scroll-p, mwheel-flip-direction)
(mwheel-scroll-left-function, mwheel-scroll-right-function): New
defcustoms.
(mouse-wheel-left-event, mouse-wheel-right-event): New variables,
events that calls wheel-left/right.

* etc/NEWS: Mention horizontal scrolling using the mouse wheel.
This commit is contained in:
Tak Kunihiro 2017-04-12 16:29:35 +03:00 committed by Eli Zaretskii
parent cc7a816936
commit 88f43dc30c
3 changed files with 67 additions and 3 deletions

View File

@ -207,6 +207,15 @@ buffers are scrolled. The variable
@code{mouse-wheel-progressive-speed} determines whether the scroll
speed is linked to how fast you move the wheel.
@vindex mwheel-tilt-scroll-p
@vindex mwheel-flip-direction
Emacs can also support horizontal scrolling if your mouse's wheel can
be tilted. This feature is off by default; the variable
@code{mwheel-tilt-scroll-p} turns it on. If you'd like to reverse the
direction of horizontal scrolling, customize the variable
@code{mwheel-flip-direction} to a non-@code{nil} value.
@node Word and Line Mouse
@section Mouse Commands for Words and Lines

View File

@ -330,6 +330,12 @@ substituted by a home directory by writing it as "/foo:/:/~/file".
settings of 'scroll-margin' up to half the window size, instead of
always restricting the margin to a quarter of the window.
+++
** Emacs can scroll horizontally using mouse, touchpad, and trackbar.
You can enable this by customizing 'mwheel-tilt-scroll-p'. If you
want to reverse the direction of the scroll, customize
'mwheel-flip-direction'.
+++
** Emacsclient has a new option -u/--suppress-output. The option
suppresses display of return values from the server process.

View File

@ -187,8 +187,8 @@ This can be slightly disconcerting, but some people prefer it."
(defun mwheel-scroll (event)
"Scroll up or down according to the EVENT.
This should be bound only to mouse buttons 4 and 5 on non-Windows
systems."
This should be bound only to mouse buttons 4, 5, 6, and 7 on
non-Windows systems."
(interactive (list last-input-event))
(let* ((selected-window (selected-window))
(scroll-window
@ -250,6 +250,16 @@ systems."
(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)))))
((eq button mouse-wheel-left-event) ; for tilt scroll
(when mwheel-tilt-scroll-p
(funcall (if mwheel-flip-direction
mwheel-scroll-right-function
mwheel-scroll-left-function) amt)))
((eq button mouse-wheel-right-event) ; for tilt scroll
(when mwheel-tilt-scroll-p
(funcall (if mwheel-flip-direction
mwheel-scroll-left-function
mwheel-scroll-right-function) amt)))
(t (error "Bad binding in mwheel-scroll"))))
(if (eq scroll-window selected-window)
;; If there is a temporarily active region, deactivate it if
@ -295,7 +305,7 @@ the mode if ARG is omitted or nil."
(global-unset-key key))))
;; Setup bindings as needed.
(when mouse-wheel-mode
(dolist (event (list mouse-wheel-down-event mouse-wheel-up-event))
(dolist (event (list mouse-wheel-down-event mouse-wheel-up-event mouse-wheel-right-event mouse-wheel-left-event))
(dolist (key (mapcar (lambda (amt) `[(,@(if (consp amt) (car amt)) ,event)])
mouse-wheel-scroll-amount))
(global-set-key key 'mwheel-scroll)
@ -307,6 +317,45 @@ the mode if ARG is omitted or nil."
"Enable mouse wheel support."
(mouse-wheel-mode (if uninstall -1 1)))
;;; For tilt-scroll
;;;
(defcustom mwheel-tilt-scroll-p nil
"Enable scroll using tilting mouse wheel."
:group 'mouse
:type 'boolean
:version "26.1")
(defcustom mwheel-flip-direction nil
"Swap direction of 'wheel-right and 'wheel-left."
:group 'mouse
:type 'boolean
:version "26.1")
(defcustom mwheel-scroll-left-function 'scroll-left
"Function that does the job of scrolling left."
:group 'mouse
:type 'function
:version "26.1")
(defcustom mwheel-scroll-right-function 'scroll-right
"Function that does the job of scrolling right."
:group 'mouse
:type 'function
:version "26.1")
(defvar mouse-wheel-left-event
(if (or (featurep 'w32-win) (featurep 'ns-win))
'wheel-left
(intern "mouse-6"))
"Event used for scrolling left.")
(defvar mouse-wheel-right-event
(if (or (featurep 'w32-win) (featurep 'ns-win))
'wheel-right
(intern "mouse-7"))
"Event used for scrolling right.")
(provide 'mwheel)
;;; mwheel.el ends here