From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: mwheel scroll horizontally Date: Mon, 04 Oct 2010 23:50:52 +0100 Organization: JURTA Message-ID: <87hbh1fu7n.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1286233062 13692 80.91.229.12 (4 Oct 2010 22:57:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 4 Oct 2010 22:57:42 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 05 00:57:40 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P2tyV-0006ea-4q for ged-emacs-devel@m.gmane.org; Tue, 05 Oct 2010 00:57:39 +0200 Original-Received: from localhost ([127.0.0.1]:47640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2tyU-0001iO-Kc for ged-emacs-devel@m.gmane.org; Mon, 04 Oct 2010 18:57:38 -0400 Original-Received: from [140.186.70.92] (port=54406 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2tyN-0001i4-3L for emacs-devel@gnu.org; Mon, 04 Oct 2010 18:57:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2tyL-0001ZD-RC for emacs-devel@gnu.org; Mon, 04 Oct 2010 18:57:30 -0400 Original-Received: from smarty.dreamhost.com ([208.113.175.8]:60168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2tyL-0001Yz-Ki for emacs-devel@gnu.org; Mon, 04 Oct 2010 18:57:29 -0400 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id B65876E8088 for ; Mon, 4 Oct 2010 15:57:27 -0700 (PDT) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id D785C451C20A for ; Mon, 4 Oct 2010 15:57:24 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131330 Archived-At: Why mwheel.el doesn't allow horizontal scrolling? The mouse wheel is indispensable for efficient scrolling around large images like maps in image-mode. For instance, Gimp allows the Shift modifier to change the direction of scrolling from vertical to horizontal. Shift and Control are already in use in mouse-wheel-scroll-amount, but Meta is available. What about using Meta for horizontal scrolling? The following patch does this. One problem is that a new format complicates the defcustom type definition. Maybe a separate customizable variable for horizontal scroll definition (e.g. `mouse-wheel-hscroll-amount') with exactly the same format as `mouse-wheel-scroll-amount' would be better? === modified file 'lisp/mwheel.el' --- lisp/mwheel.el 2010-08-30 18:48:02 +0000 +++ lisp/mwheel.el 2010-10-04 22:44:45 +0000 @@ -99,7 +99,10 @@ (defcustom mouse-wheel-inhibit-click-tim :group 'mouse :type 'number) -(defcustom mouse-wheel-scroll-amount '(5 ((shift) . 1) ((control) . nil)) +(defcustom mouse-wheel-scroll-amount '(5 ((shift) . 1) ((control) . nil) + ((meta) . (hscroll . 5)) + ((meta shift) . (hscroll . 1)) + ((meta control) . (hscroll . nil))) "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. @@ -123,7 +126,13 @@ (defcustom mouse-wheel-scroll-amount '(5 (choice :tag "scroll amount" (const :tag "Full screen" :value nil) (integer :tag "Specific # of lines") - (float :tag "Fraction of window")))) + (float :tag "Fraction of window") + (cons + (const :tag "Horizontal scroll" :value hscroll) + (choice :tag "scroll amount" + (const :tag "Full screen" :value nil) + (integer :tag "Specific # of lines") + (float :tag "Fraction of window")))))) (repeat (cons (repeat (choice :tag "modifier" @@ -132,7 +141,13 @@ (defcustom mouse-wheel-scroll-amount '(5 (choice :tag "scroll amount" (const :tag "Full screen" :value nil) (integer :tag "Specific # of lines") - (float :tag "Fraction of window"))))) + (float :tag "Fraction of window") + (cons + (const :tag "Horizontal scroll" :value hscroll) + (choice :tag "scroll amount" + (const :tag "Full screen" :value nil) + (integer :tag "Specific # of lines") + (float :tag "Fraction of window"))))))) :set 'mouse-wheel-change-button) (defcustom mouse-wheel-progressive-speed t @@ -186,6 +201,12 @@ (defvar mwheel-scroll-up-function 'scrol (defvar mwheel-scroll-down-function 'scroll-down "Function that does the job of scrolling downward.") +(defvar mwheel-scroll-left-function 'scroll-left + "Function that does the job of scrolling left.") + +(defvar mwheel-scroll-right-function 'scroll-right + "Function that does the job of scrolling right.") + (defun mwheel-scroll (event) "Scroll up or down according to the EVENT. This should only be bound to mouse buttons 4 and 5." @@ -200,9 +221,16 @@ (defun mwheel-scroll (event) (point)))) (mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) - (amt (assoc mods mouse-wheel-scroll-amount))) - ;; Extract the actual amount or find the element that has no modifiers. - (if amt (setq amt (cdr amt)) + (amt (assoc mods mouse-wheel-scroll-amount)) + hscroll) + (if amt + ;; Extract the actual amount. + (progn + (setq amt (cdr amt)) + ;; Set hscroll for horizontal scroll. + (when (eq (car-safe amt) 'hscroll) + (setq hscroll t amt (cdr amt)))) + ;; Else find the element that has no modifiers. (let ((list-elt mouse-wheel-scroll-amount)) (while (consp (setq amt (pop list-elt)))))) (if (floatp amt) (setq amt (1+ (truncate (* amt (window-height)))))) @@ -212,7 +240,12 @@ (defun mwheel-scroll (event) (setq amt (* amt (event-click-count event)))) (unwind-protect (let ((button (mwheel-event-button event))) - (cond ((eq button mouse-wheel-down-event) + (cond (hscroll + (cond ((eq button mouse-wheel-down-event) + (funcall mwheel-scroll-right-function amt)) + ((eq button mouse-wheel-up-event) + (funcall mwheel-scroll-left-function amt)))) + ((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.