all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* looking up a submenu keymap in a menu keymap, when the submenu key is a string
@ 2006-10-08 18:34 Drew Adams
  2006-10-09  1:02 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2006-10-08 18:34 UTC (permalink / raw)


I can't seem to find the answer to this in the Elisp doc. Perhaps it's
there, but I've spent a lot of time looking and haven't discovered it. It's
possible I read the answer without recognizing it. I've also looked closely
at several Emacs-Lisp source files, to try to understand better and perhaps
find a model for what I'm trying to do. No luck so far.

How can I look up a menu item that is a submenu in a keymap, and whose key
(or item-string) is a string, not a symbol? That is, how can I pass the
submenu menu-item string to some function and have it return the keymap for
that submenu?

For example, in this Imenu keymap, which is the result of (lookup-key
(current-local-map) [menu-bar index]), how can I look up the "Variables"
keymap:

(keymap "foo.el"
        ("Variables" "Variables" keymap "Variables"
         ("toto" "toto" lambda nil
          (interactive)
          (imenu--menubar-select
           '("toto" . #<marker at 37004 in foo.el>)))))

IOW, what would I use to obtain from the Imenu keymap the following submenu
map, given the menu-item string for the submenu, "Variables"?

(keymap "Variables"
        ("toto" "toto" lambda nil
         (interactive)
         (imenu--menubar-select
          '("toto" . #<marker at 37004 in foo.el>))))

`lookup-key' doesn't seem to help here - at least I cannot just pass
"Variables" as the key arg to it. And passing the symbol `Variables' to it
obviously doesn't work either, since the key in the map itself is a string.

If Variables in the keymap were a key (event) instead of a string, I could
do (lookup-key (current-local-map) [menu-bar index Variables]) or
(lookup-key (lookup-key (current-local-map) [menu-bar index]) 'Variables).
IOW, if the submenu item were like this, there would be no problem:

(Variables "Variables" keymap "Variables"
 ("toto" "toto" lambda nil
  (interactive)
  (imenu--menubar-select
   '("toto" . #<marker at 37004 in foo.el>))))

But, how do I deal with a string "Variables" as the key (which is the
item-string) here? In other menus, I usually see a symbol as the key for a
submenu, but for Imenu it is always a string.

Please let me know what I'm missing - thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-10-10  1:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-08 18:34 looking up a submenu keymap in a menu keymap, when the submenu key is a string Drew Adams
2006-10-09  1:02 ` Stefan Monnier
2006-10-09  1:27   ` Drew Adams
2006-10-09  5:07     ` Stefan Monnier
2006-10-09 15:36       ` Drew Adams
2006-10-09 16:57         ` Stefan Monnier
2006-10-10  1:31           ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.