aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorTak Kunihiro2017-04-12 16:29:35 +0300
committerEli Zaretskii2017-04-12 16:29:35 +0300
commit88f43dc30cb8d71830e409973cafbaca13a66a45 (patch)
tree1d4882e9666dd75164c6255ce60693f1808b179d /lisp
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mwheel.el55
1 files changed, 52 insertions, 3 deletions
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