From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#4478: 23.1; key bindings for mouse wheel - unclear Date: Fri, 18 Sep 2009 09:34:14 -0400 Message-ID: References: <625E5DF5465B4A1CBF3FBB6015CBB87D@us.oracle.com> Reply-To: Stefan Monnier , 4478@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253282572 3403 80.91.229.12 (18 Sep 2009 14:02:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Sep 2009 14:02:52 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, 4478@emacsbugs.donarmstrong.com To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 18 16:02:44 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Moe2u-0004jF-2U for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Sep 2009 16:02:44 +0200 Original-Received: from localhost ([127.0.0.1]:51297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Moe2t-0006Iw-M6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Sep 2009 10:02:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Modnp-00058G-Ld for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:47:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Modnl-00056U-Mg for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:47:09 -0400 Original-Received: from [199.232.76.173] (port=41027 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Modnl-000569-DW for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:47:05 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:60106) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Modnk-0003B4-L7 for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:47:04 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8IDl1Y8024092; Fri, 18 Sep 2009 06:47:02 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n8IDe6S2023082; Fri, 18 Sep 2009 06:40:06 -0700 Resent-Date: Fri, 18 Sep 2009 06:40:06 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Fri, 18 Sep 2009 13:40:06 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4478 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125328086322276 (code B ref -1); Fri, 18 Sep 2009 13:40:06 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 18 Sep 2009 13:34:23 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8IDYLsW022269 for ; Fri, 18 Sep 2009 06:34:22 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ModbR-0003Tu-1z for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:34:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ModbM-0003OI-5e for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:34:20 -0400 Original-Received: from [199.232.76.173] (port=58292 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ModbL-0003O3-Up for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:34:16 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:10175 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ModbL-0000wR-EA for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2009 09:34:15 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtYEACcps0pLd/GK/2dsb2JhbACBUs1JhBwFh34 X-IronPort-AV: E=Sophos;i="4.44,409,1249272000"; d="scan'208";a="46009611" Original-Received: from 75-119-241-138.dsl.teksavvy.com (HELO pastel.home) ([75.119.241.138]) by ironport2-out.pppoe.ca with ESMTP; 18 Sep 2009 09:34:14 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 6BB2E801B; Fri, 18 Sep 2009 09:34:14 -0400 (EDT) In-Reply-To: <625E5DF5465B4A1CBF3FBB6015CBB87D@us.oracle.com> (Drew Adams's message of "Fri, 18 Sep 2009 00:48:12 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Fri, 18 Sep 2009 09:47:09 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:31216 Archived-At: > 1. Doc bug: The doc is not clear about how to bind the mouse wheel > (rotations). Indeed. The way to do it is currently messy and ugly. > I've been using bindings such as this: > (define-key map [wheel-down] 'aaa) > (define-key map [wheel-down] 'bbb) > (define-key map [C-wheel-down] 'ccc) > (define-key map [C-wheel-down] 'ddd) IIUC this is "the right way". And it works under w32 and ns. Under X11, sadly, mouse-wheel events are usually represented as mouse clicks for buttons 4 and 5, and there's no way for Emacs to know whether these correspond to mouse clicks (on mice with more than 3 buttons) or mouse-wheel events. Worse yet, Emacs doesn't offer an easy way to map all the variants of `mouse-4' and `mouse-5' (with and without each of the possible modifiers) to wheel-up and wheel-down. The code appended below does manage to do such a remap, but as you can see it's ugly, and worse yet: there can only be one such thing because it uses the "default" binding. [ And it probably won't work with xterm-mouse-mode. ] > (define-key map (vector mouse-wheel-down-event) 'aaa) > (define-key map (vector mouse-wheel-up-event) 'bbb) > (define-key map > (vector (list 'control mouse-wheel-down-event)) 'ccc) > (define-key map > (vector (list 'control mouse-wheel-up-event)) 'ddd) > I haven't tested on GNU/Linux, but I'm assuming this is what to use > for portable code. Is there a shorter or better way to say this and > still be portable? I think this is about as good as it gets for now, yes. > 1. If there is not, there should be (a shorter way to do this). The [wheel-down] and friends shown above is what there should be. Stefan (define-key function-key-map [t] '(menu-item "" nil :filter sm-rewrite-mwheel)) (defun sm-rewrite-mwheel (ignore) (let* ((events (this-single-command-raw-keys)) (event (unless (zerop (length events)) (aref events (1- (length events)))))) (message "sm-rewrite-mwheel: key=%s" event) (case (event-basic-type event) (mouse-4 (let* ((mods (delete 'click (event-modifiers event))) (new-key (event-convert-list (append mods '(wheel-up)))) (new-event (cons new-key (cdr event)))) (vector new-event))) (mouse-5 (let* ((mods (delete 'click (event-modifiers event))) (new-key (event-convert-list (append mods '(wheel-down)))) (new-event (cons new-key (cdr event)))) (vector new-event))))))