@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
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.
(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
(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
(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)
"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