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: looking up a submenu keymap in a menu keymap, when the submenu key is a string Date: Mon, 9 Oct 2006 08:36:25 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1160408284 6733 80.91.229.2 (9 Oct 2006 15:38:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Oct 2006 15:38:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 09 17:37:57 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GWxBc-0000ut-7x for ged-emacs-devel@m.gmane.org; Mon, 09 Oct 2006 17:37:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GWxBb-0003sK-00 for ged-emacs-devel@m.gmane.org; Mon, 09 Oct 2006 11:36:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GWxBN-0003ps-Rq for emacs-devel@gnu.org; Mon, 09 Oct 2006 11:36:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GWxBJ-0003oK-5d for emacs-devel@gnu.org; Mon, 09 Oct 2006 11:36:44 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GWxBI-0003ns-U5 for emacs-devel@gnu.org; Mon, 09 Oct 2006 11:36:40 -0400 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 1GWxIs-0001CJ-3A for emacs-devel@gnu.org; Mon, 09 Oct 2006 11:44:30 -0400 Original-Received: from rgmsgw01.us.oracle.com (rgmsgw01.us.oracle.com [138.1.186.51]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id k99FaWlw009904 for ; Mon, 9 Oct 2006 10:36:33 -0500 Original-Received: from dradamslap (dhcp-amer-whq-csvpn-gw3-141-144-83-154.vpn.oracle.com [141.144.83.154]) by rgmsgw01.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with SMTP id k99FaVl5001290 for ; Mon, 9 Oct 2006 09:36:32 -0600 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) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Importance: Normal X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE 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:60543 Archived-At: > You can try to pass ["Variables"]. But it's really not that > simple, since you have to distinguish between the menu name > and the "pseudo-key" associated with it. In your examples, > both are strings and they are equal, > but that's not necessarily the case. > You may want o check the easy-menu functions for that, > tho they're not always as "easy" to use as the name implies. > Right. Thanks for your reply. I did try ["Variables"] (and > [menu-bar index "Variables"]), This can work, but the test is `eq' rather than `equal' so you have to pass not just some random "Variables" string, but the very one used in the keymap. I suspected that. I don't have that information at the time I'm querying, at least not the way I'm doing things now. I save the exact binding (command or keymap), but for the key bound to it I save only the external name of the key (a string). > and I did study the easy-menu stuff. The easy-menu stuff > almost seemed as if it was going to get me what I needed, but I wasn't > able to make it work. Other suggestions are welcome, from anyone. I think easy-menu is the way to go. Tell us what you tried. Of course, it may also be important to know the context in which you're doing that: maybe there's a simpler way. I will have to look at this again later - perhaps next weekend. > If there is no easy (or even feasible) way to do this, I > wonder if it isn't a mistake to "allow", or at least encourage, > this kind of keymap entry - Imenu is a standard library. It's definitely not encouraged, but it should mostly be irrelevant, because it's an internal issue. Normally, either you have the key already (from read-key-sequence, for example), or you have the menu entry name (in which case you have to use code such as the one used in easy-menu to scan the keymap and recover the corresponding key). I map over a keymap with `map-keymap', so I have the `event' and `binding' arguments. I build an alist of (name . binding) pairs, where `name' is a string that includes external names of the key and its command, or "..." for a prefix map - examples: "C-a = beginning-of-line" "C-x = ..." I can pick up the Imenu prefix map (`index') OK, but I haven't been able to pick up its entries (e.g. submenus) on a recursive call. I've tried to treat all the various key-binding cases, but it's possible I've overlooked something. As I say, when I get a chance, I'll take another stab at it. The code is here, if anyone would like to take a look: http://www.emacswiki.org/cgi-bin/wiki/icicles-cmd.el. The function that builds the alist is `icicle-keys+cmds-w-prefix'. The function that does alist lookup later is `icicle-complete-keys(-1)'. Right now, I've excluded the Imenu menus, because I can't handle them properly. To disable that exclusion, take out the line that has the comment "Skip Imenu menu". To try this in context interactively, you'll need the other Icicles libraries too: http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Libraries. This feature is bound to `S-TAB' when in Icicles minor mode - use `S-TAB' to navigate the key-binding hierarchy (`..' to go up; `...' to go down into a prefix map). When you try to descend into the keymap `menubar', then `index' (which is Imenu), then a submenu (such as `Variables'), you get error "No keys for prefix `[menu-bar index Variables]'". Right now, the code looks for this submenu keymap as [Variables], not as ["Variables"] with the exact string from the keymap. Thx.