emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: looking up a submenu keymap in a menu keymap, when the submenu key i


From: Drew Adams
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

    >     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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]