aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTak Kunihiro2017-04-12 16:29:35 +0300
committerEli Zaretskii2017-04-12 16:29:35 +0300
commit88f43dc30cb8d71830e409973cafbaca13a66a45 (patch)
tree1d4882e9666dd75164c6255ce60693f1808b179d
parentcc7a81693638f25cac65bbab013fc23da1ef4bcc (diff)
downloademacs-88f43dc30cb8d71830e409973cafbaca13a66a45.tar.gz
emacs-88f43dc30cb8d71830e409973cafbaca13a66a45.zip
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.
-rw-r--r--doc/emacs/frames.texi9
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/mwheel.el55
3 files changed, 67 insertions, 3 deletions
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index d1fd4d0446e..68c12d272f8 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -207,6 +207,15 @@ buffers are scrolled. The variable
207@code{mouse-wheel-progressive-speed} determines whether the scroll 207@code{mouse-wheel-progressive-speed} determines whether the scroll
208speed is linked to how fast you move the wheel. 208speed is linked to how fast you move the wheel.
209 209
210@vindex mwheel-tilt-scroll-p
211@vindex mwheel-flip-direction
212Emacs can also support horizontal scrolling if your mouse's wheel can
213be tilted. This feature is off by default; the variable
214@code{mwheel-tilt-scroll-p} turns it on. If you'd like to reverse the
215direction of horizontal scrolling, customize the variable
216@code{mwheel-flip-direction} to a non-@code{nil} value.
217
218
210@node Word and Line Mouse 219@node Word and Line Mouse
211@section Mouse Commands for Words and Lines 220@section Mouse Commands for Words and Lines
212 221
diff --git a/etc/NEWS b/etc/NEWS
index 3c328ac58a2..799a2b31e56 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -331,6 +331,12 @@ settings of 'scroll-margin' up to half the window size, instead of
331always restricting the margin to a quarter of the window. 331always restricting the margin to a quarter of the window.
332 332
333+++ 333+++
334** Emacs can scroll horizontally using mouse, touchpad, and trackbar.
335You can enable this by customizing 'mwheel-tilt-scroll-p'. If you
336want to reverse the direction of the scroll, customize
337'mwheel-flip-direction'.
338
339+++
334** Emacsclient has a new option -u/--suppress-output. The option 340** Emacsclient has a new option -u/--suppress-output. The option
335suppresses display of return values from the server process. 341suppresses display of return values from the server process.
336 342
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 958c6e831b7..73fd2b7e115 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -187,8 +187,8 @@ This can be slightly disconcerting, but some people prefer it."
187 187
188(defun mwheel-scroll (event) 188(defun mwheel-scroll (event)
189 "Scroll up or down according to the EVENT. 189 "Scroll up or down according to the EVENT.
190This should be bound only to mouse buttons 4 and 5 on non-Windows 190This should be bound only to mouse buttons 4, 5, 6, and 7 on
191systems." 191non-Windows systems."
192 (interactive (list last-input-event)) 192 (interactive (list last-input-event))
193 (let* ((selected-window (selected-window)) 193 (let* ((selected-window (selected-window))
194 (scroll-window 194 (scroll-window
@@ -250,6 +250,16 @@ systems."
250 (condition-case nil (funcall mwheel-scroll-up-function amt) 250 (condition-case nil (funcall mwheel-scroll-up-function amt)
251 ;; Make sure we do indeed scroll to the end of the buffer. 251 ;; Make sure we do indeed scroll to the end of the buffer.
252 (end-of-buffer (while t (funcall mwheel-scroll-up-function))))) 252 (end-of-buffer (while t (funcall mwheel-scroll-up-function)))))
253 ((eq button mouse-wheel-left-event) ; for tilt scroll
254 (when mwheel-tilt-scroll-p
255 (funcall (if mwheel-flip-direction
256 mwheel-scroll-right-function
257 mwheel-scroll-left-function) amt)))
258 ((eq button mouse-wheel-right-event) ; for tilt scroll
259 (when mwheel-tilt-scroll-p
260 (funcall (if mwheel-flip-direction
261 mwheel-scroll-left-function
262 mwheel-scroll-right-function) amt)))
253 (t (error "Bad binding in mwheel-scroll")))) 263 (t (error "Bad binding in mwheel-scroll"))))
254 (if (eq scroll-window selected-window) 264 (if (eq scroll-window selected-window)
255 ;; If there is a temporarily active region, deactivate it if 265 ;; If there is a temporarily active region, deactivate it if
@@ -295,7 +305,7 @@ the mode if ARG is omitted or nil."
295 (global-unset-key key)))) 305 (global-unset-key key))))
296 ;; Setup bindings as needed. 306 ;; Setup bindings as needed.
297 (when mouse-wheel-mode 307 (when mouse-wheel-mode
298 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event)) 308 (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event mouse-wheel-right-event mouse-wheel-left-event))
299 (dolist (key (mapcar (lambda (amt) `[(,@(if (consp amt) (car amt)) ,event)]) 309 (dolist (key (mapcar (lambda (amt) `[(,@(if (consp amt) (car amt)) ,event)])
300 mouse-wheel-scroll-amount)) 310 mouse-wheel-scroll-amount))
301 (global-set-key key 'mwheel-scroll) 311 (global-set-key key 'mwheel-scroll)
@@ -307,6 +317,45 @@ the mode if ARG is omitted or nil."
307 "Enable mouse wheel support." 317 "Enable mouse wheel support."
308 (mouse-wheel-mode (if uninstall -1 1))) 318 (mouse-wheel-mode (if uninstall -1 1)))
309 319
320
321;;; For tilt-scroll
322;;;
323(defcustom mwheel-tilt-scroll-p nil
324 "Enable scroll using tilting mouse wheel."
325 :group 'mouse
326 :type 'boolean
327 :version "26.1")
328
329(defcustom mwheel-flip-direction nil
330 "Swap direction of 'wheel-right and 'wheel-left."
331 :group 'mouse
332 :type 'boolean
333 :version "26.1")
334
335(defcustom mwheel-scroll-left-function 'scroll-left
336 "Function that does the job of scrolling left."
337 :group 'mouse
338 :type 'function
339 :version "26.1")
340
341(defcustom mwheel-scroll-right-function 'scroll-right
342 "Function that does the job of scrolling right."
343 :group 'mouse
344 :type 'function
345 :version "26.1")
346
347(defvar mouse-wheel-left-event
348 (if (or (featurep 'w32-win) (featurep 'ns-win))
349 'wheel-left
350 (intern "mouse-6"))
351 "Event used for scrolling left.")
352
353(defvar mouse-wheel-right-event
354 (if (or (featurep 'w32-win) (featurep 'ns-win))
355 'wheel-right
356 (intern "mouse-7"))
357 "Event used for scrolling right.")
358
310(provide 'mwheel) 359(provide 'mwheel)
311 360
312;;; mwheel.el ends here 361;;; mwheel.el ends here