help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Assigning keymaps / menu shorts / changing menu items


From: Stefan Monnier
Subject: Re: Assigning keymaps / menu shorts / changing menu items
Date: Sun, 10 Apr 2005 16:28:52 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

>> Find the key-sequence corresponding to it with C-h k, then
>> (define-key [theseysequence] '(menu-item ...)).
>> See the elisp manual's description of menus and `menu-item' for more info.

> OK, but I wouldn't want to contruct a completely new menu-item, I would just
> want to exchange the text. Now, when I do something like

> (lookup-key global-map [menu-bar file open-file])

> all I get is the pure command, 'find-file-existing, in this case - but not
> the arguments :enable and :help that were defined in menu-bar.el:

Yes, that's a problem I'm familar with.  It should be pretty easy to fix,
all we need is a way to tell lookup-key to return the "raw" binding.
Please send a feature request to gnu.emacs.bug about it.

As a workaround you can try

   (cdr (assq 'open-file (lookup-key global-map [menu-bar file])))

which will probably work in most cases.  Note that doing a `setcar' or
`setcdr' operation on the menu-item you found, tho appealing, should be
avoided since it may fail (this data is often located in pure-storage
which is readonly).  Instead you'll have to reconstruct a new menu-item with
most of the content unchanged, using non-destructive operators like
`append', `cons', ...


        Stefan




reply via email to

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