From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Fabian Ezequiel Gallina Newsgroups: gmane.emacs.devel Subject: Re: Key Mapping Proposal Date: Sat, 16 Jan 2010 04:57:38 -0300 Message-ID: <9de1a5ef1001152357u45eb42d8g7d48fee1b885e910@mail.gmail.com> References: <16d22e431001151603i5d2fab77u4f3054bb7e708323@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1263628680 20274 80.91.229.12 (16 Jan 2010 07:58:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Jan 2010 07:58:00 +0000 (UTC) Cc: emacs-devel@gnu.org To: Noah Lavine Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 16 08:57:52 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.50) id 1NW3Xb-0006vQ-D7 for ged-emacs-devel@m.gmane.org; Sat, 16 Jan 2010 08:57:51 +0100 Original-Received: from localhost ([127.0.0.1]:57275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NW3Xc-00069j-B0 for ged-emacs-devel@m.gmane.org; Sat, 16 Jan 2010 02:57:52 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NW3XX-00068a-5C for emacs-devel@gnu.org; Sat, 16 Jan 2010 02:57:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NW3XS-00065b-Hl for emacs-devel@gnu.org; Sat, 16 Jan 2010 02:57:46 -0500 Original-Received: from [199.232.76.173] (port=43837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NW3XS-00065Y-DW for emacs-devel@gnu.org; Sat, 16 Jan 2010 02:57:42 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]:63810) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NW3XR-0001cM-Nt for emacs-devel@gnu.org; Sat, 16 Jan 2010 02:57:41 -0500 Original-Received: from mail-fx0-f228.google.com ([209.85.220.228]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NW3XQ-0008Mp-Cj for emacs-devel@gnu.org; Sat, 16 Jan 2010 02:57:40 -0500 Original-Received: by fxm28 with SMTP id 28so419567fxm.26 for ; Fri, 15 Jan 2010 23:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=3Gq0UfzTSnBWbN6ucDab6B3ejzQonYgzqxf0n2oYvbE=; b=NHFyehT7M7bS8c6krSVS9JhiXwKeXJlKEzl07h6gP5sErGODjTEGWkhqWIkMgsQrUg bOpXe477X2fUUIjmXH26bu7nKbWuXPqmvdMWhvTTrCTPsYimiu4G6/ZaqPFuK3pUBv/U 54Vh8UElSBzV5nuhqZPYmYHQnBvQqopZ+8v6I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Rm2cgs+8sRjtCbPK9LLRdwsNI1aZ1JHLkGEktHQEZZWSy2H3DjY0uXVNpkDePqpEmt yj6yDc6eX7UgoND1nUMadzTqAXt4S7wDbDVhf5aWyKvq4eS7JsjUmsZMfDl+ouNF3JYe hfTVl70Wc3gSBT6npzDiQQ4XuTysvdWI7W610= Original-Received: by 10.87.15.22 with SMTP id s22mr1074946fgi.56.1263628658461; Fri, 15 Jan 2010 23:57:38 -0800 (PST) In-Reply-To: <16d22e431001151603i5d2fab77u4f3054bb7e708323@mail.gmail.com> X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:120090 Archived-At: 2010/1/15 Noah Lavine : > Dear emacs-devel, > > I'd like to suggest a change to the way modes bind keys, to make it > easier for users to customize keys. > > Right now, as far as I can tell, each mode defines some functions and > then binds the appropriate keys to them. There are certain keys that > have conventional meanings, so "C-f" means forward even if you're in > picture-mode, and so on, and modes all try to respect this. The > problem comes if you want to change the meaning of not just one key > sequence, but the convention. Some people might like to use C-f, C-d, > C-s, and C-e to move forward, down, back and up, because they're right > next to each other. In order to achieve this now, you would need to > rebind those keys in each mode that you use. It seems like there > should be a better way. > > My suggestion is this: have one location which stores the user's > keybinding for the "forward" key, whatever "forward" means for a > particular mode. Any given mode would then use this to bind their > particular "forward" function to whatever key the user wanted. Do the > same for other keys with conventional meaning, and then modify the > major modes to use these in their keybindings. > > One issue that might occur is if the user's bindings for a > conventional key conflict with a binding unique to one particular > major mode. You'd want a system for bouncing the other bindings around > to prevent this, perhaps by keeping a list of unbound keys and then > assigning the functions that need bindings to those keys one by one. > This would give up the ability to give mnemonic key bindings to > functions, but the issue would only occur if the user was customizing > their keys, in which case it seems like the user's preferences should > take priority. > > I'm happy to contribute work to this, but I wanted to ask emacs-devel > first to see if you were interested in this, and if so, what you > thought the right approach was. > > Thank you > Noah Lavine > I agree it is a good idea, my guess is that this could be achieved if modes use `substitute-key-definition' to define analog commands for standard commands (forward-char, backward-char, etc) like this: (defvar my-mode-map (let ((my-mode-map (make-sparse-keymap))) (define-key my-mode-map "\C-ch" 'my-do-something) (substitute-key-definition 'forward-char 'my-forward-char my-mode-map (current-global-map)))) This way if I rebind C-f (forward-char) to M-f globally this should make M-f to call my-forward-char when i'm using my-mode. (global-set-key (kbd "M-f") 'forward-char) So my guess is that it is just a matter of fixing that on every mode not using `substitute-key-definition' for standard commands. Regards, --=20 Fabi=E1n E. Gallina http://www.from-the-cloud.com