From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Uday S Reddy Newsgroups: gmane.emacs.devel Subject: Re: Key bindings proposal [Was: Emacs learning curve] Date: Thu, 29 Jul 2010 12:26:27 +0100 Message-ID: <19537.25955.517000.314148@gargle.gargle.HOWL> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1280402818 2155 80.91.229.12 (29 Jul 2010 11:26:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Jul 2010 11:26:58 +0000 (UTC) Cc: u.s.reddy@cs.bham.ac.uk, emacs-devel@gnu.org To: Noah Lavine Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 29 13:26:56 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 1OeRGG-00057G-3Y for ged-emacs-devel@m.gmane.org; Thu, 29 Jul 2010 13:26:52 +0200 Original-Received: from localhost ([127.0.0.1]:58491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeRGF-0004rA-6E for ged-emacs-devel@m.gmane.org; Thu, 29 Jul 2010 07:26:51 -0400 Original-Received: from [140.186.70.92] (port=35722 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeRG9-0004pW-2T for emacs-devel@gnu.org; Thu, 29 Jul 2010 07:26:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeRG7-0008W3-P5 for emacs-devel@gnu.org; Thu, 29 Jul 2010 07:26:44 -0400 Original-Received: from sun60.bham.ac.uk ([147.188.128.137]:60327) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeRG7-0008VZ-K6 for emacs-devel@gnu.org; Thu, 29 Jul 2010 07:26:43 -0400 Original-Received: from [147.188.128.127] (helo=bham.ac.uk) by sun60.bham.ac.uk with esmtp (Exim 4.67) (envelope-from ) id 1OeRG5-0001xq-Nt; Thu, 29 Jul 2010 12:26:41 +0100 Original-Received: from mx1.cs.bham.ac.uk ([147.188.192.53]) by bham.ac.uk with esmtp (Exim 4.43) id 1OeRG5-0007Fz-E1; Thu, 29 Jul 2010 12:26:41 +0100 Original-Received: from gromit.cs.bham.ac.uk ([147.188.193.16] helo=MARUTI.cs.bham.ac.uk) by mx1.cs.bham.ac.uk with esmtp (Exim 4.51) id 1OeRG5-0006wD-36; Thu, 29 Jul 2010 12:26:41 +0100 In-Reply-To: X-Mailer: VM 8.1.92a under 23.2.1 (i386-mingw-nt5.1.2600) X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) 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:127957 Archived-At: Noah Lavine writes: > I am writing because I am trying to understand exactly what the > keybindings proposal requires. As I understand it, this chain of > events will produce an undesired result: > > 1. Global keymap says "C-y" -> yank > 2. You map "C-z" -> yank and send "C-y" to something else > 3. Gzip major mode says "C-z" -> compress and "C-y" -> gzip-special-yank > > At this point typing "C-z" runs 'compress' and typing "C-y" runs > 'gzip-special-yank', whereas the desired result was that "C-z" would > be gzip-special-yank and "C-y" would be compress, because you have > indicated your preference that "C-z" be used for yank instead of > "C-y". Nice example! If the Gzip major mode (is there such a thing?) defines direct key bindings as in your line 3, then the user is stuck. He has to alter the Gzip mode map in addition to altering the global map. The remapping idea is that the Gzip major mode can remap `yank' to `gzip-special-yank' (and continue to bind "C-z" to `compress'). If it does that, there will be a conflict when its keymap is constructed. There are two competing bindings for "C-z". My proposal says that this conflict should be detected when the keymap is constructed and there should be a rule about how to resolve the conflict. If the rule says that remapped bindings should take priority, then "C-z" should get bound to `gzip-special-yank' and there won't be a key for `compress'. If the rule says that direct key bindings should take priority, then one gets the native key bindings of Gzip mode. ("C-z" -> compress and "C-y" -> gzip-special-yank). The current remap implementation in Emacs 23 doesn't detect any conflict when it constructs the keymap. However, the semantics of remap seems to have the effect that the direct key bindings take priority. (Working this out is a bit tricky. The semantics is that, when a key is pressed, if its binding happens to be `yank' then Gzip will substitute it by `gzip-special-yank'. But because of line 2, there is no key you can press in Gzip mode to get `yank'. So, you get the native bindings.) The remap semantics is a "call-by-name" feature in an otherwise call-by-value programming language, which might be confusing in itself but its effect is to give the least possible priority to remap. > Remap would not accomplish this (at least not by itself), because > there is no standard command analogous to 'compress' that gzip-mode > should have remapped. However, as long as there is a command > anywhere in the keymap that is analogous to yank, then "C-z" should > have been mapped to that, and its keybinding moved as necessary > (perhaps to "C-y"). > > Is this an accurate statement of the idea? Yes, it is close enough a description of what remap needs to do to satisfy my requirements. Except that I am not requiring that Emacs should invent a key binding for `compress' on its own! Nobody would fault Emacs if "C-z" = `compress' is a binding specific to Gzip. But they would fault it for ignoring the user's preference to bind "C-z" = yank. Cheers, Uday