From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: menu indications of key bindings for remapped commands Date: Thu, 11 Jan 2007 18:06:58 -0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1168567675 16285 80.91.229.12 (12 Jan 2007 02:07:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 12 Jan 2007 02:07:55 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 12 03:07:52 2007 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 1H5BpX-0001Kl-QB for ged-emacs-devel@m.gmane.org; Fri, 12 Jan 2007 03:07:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H5BpX-0004ni-Lw for ged-emacs-devel@m.gmane.org; Thu, 11 Jan 2007 21:07:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H5BpL-0004ll-FO for emacs-devel@gnu.org; Thu, 11 Jan 2007 21:07:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H5BpJ-0004ji-Pz for emacs-devel@gnu.org; Thu, 11 Jan 2007 21:07:31 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H5BpJ-0004jb-OQ for emacs-devel@gnu.org; Thu, 11 Jan 2007 21:07:29 -0500 Original-Received: from [141.146.126.228] (helo=agminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H5BpI-0007wD-LE for emacs-devel@gnu.org; Thu, 11 Jan 2007 21:07:29 -0500 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l0C27Q6g024151 for ; Thu, 11 Jan 2007 20:07:26 -0600 Original-Received: from rcsmt250.oracle.com (rcsmt250.oracle.com [148.87.90.195]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l0BG0NqP008294 for ; Thu, 11 Jan 2007 19:07:25 -0700 Original-Received: from dhcp-amer-csvpn-gw1-141-144-65-120.vpn.oracle.com by rcsmt250.oracle.com with ESMTP id 2357342101168567619; Thu, 11 Jan 2007 19:06:59 -0700 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: Importance: Normal X-Whitelist: TRUE X-Whitelist: TRUE X-Brightmail-Tracker: AAAAAQAAAAI= 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:65158 Archived-At: I think I've discovered what the problem is. IMO, there is a bug in the definition of menu items. As Kim pointed out, ido has no such problem. However, ido does not create a menu item; it simply remaps a command that was already used in a menu item - e.g., command `switch-to-buffer', used in "Buffers" menu item "Select Named Buffer... (C-x b)". It is the binding of the command `switch-to-buffer' that is reflected in that menu item. The menu item calls command `ido-switch-buffer', but the binding displayed is that of `switch-to-buffer', not that of `ido-switch-buffer'. In my case, I create menu items, both in standard menus such as "File" and in a new menu, "Icicles". But that's not the difference that matters. When I create a menu item for buffer switching, I use a new command, `icicle-buffer', which is the target of a command remapping. I have this: (define-key icicle-mode-map [remap switch-to-buffer] 'icicle-buffer) And it is the new command `icicle-buffer', not the remapped command `switch-to-buffer', that I use to define the menu item: (define-key icicle-menu-map [icicle-buffer] '("+ Switch to Buffer..." . icicle-buffer))) ^^^^^^^^^^^^^ It is the immediate binding of the command `icicle-buffer', "( )", that is reflected in the menu item. From a user point of view, it is only the ultimate, user-friendly key binding that is of interest, that is, the binding of the remapped command, `switch-to-buffer'. It is that binding, "(C-x b)", that should be displayed in the menu item. Showing "( )" to the user is a bug, IMO. If I use the remapped command, `switch-to-buffer', in the menu-item definition, then the correct key binding, "(C-x b)", does indeed show up in the menu item: (define-key icicle-menu-map [icicle-buffer] '("+ Switch to Buffer..." . switch-to-buffer))) ^^^^^^^^^^^^^^^^ But it is handy and more readable to use the new command that is the remap target, `icicle-buffer', not the remapped command, `switch-to-buffer', in the menu-item definition. A library will typically want to express everything in terms of its own command, and then have a single remapping that references the remapped command. And it is possible that the remapped command has no key binding at runtime - in that case, the menu item should show no key binding; it should not show (...). The bottom line is that the key-binding indication in a menu item should be as helpful as possible to the user. So, I see two use cases: 1. (ido use case) Remap a command that was already used to define a menu item. 2. (icicles use case) Define a new menu item, using a command that is a remap target. (The remapped command might or might not itself also be already used to define a different menu item.) The key binding shown in the menu item should in both cases be user-friendly (C-x b), that is, regardless of which command is used in the menu-item definition: remap source or remap target. In the case of Icicles, the "Buffers" menu item "Select Named Buffer..." does show the user-friendly binding "(C-x b)", because it is a pre-existing menu item that was defined using command `switch-to-buffer'. The same key binding should also be shown for a new menu item that is defined using the remap target, `icicle-buffer'. The user should see only the final key binding - what s?he types, which is always the binding of the remap source (`switch-to-buffer', in this case). The fix is to treat a remap target the same way: always get and use the ultimate key binding in the menu item.