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: Sat, 09 Apr 2005 15:15:01 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I understand the menu item shortcuts show what's defined first. Is there
> a command like global-set-key that would insert the new keymap at the
> beginning of the list associated with the function? Here's what I do:

> (global-set-key [(alt v)] 'yank)

> 'yank has a menu entry in the Edit menu that currently says "Paste (C-y)".

The shortcuts displayed in the menus try not only to only mention *key*
bindings, but also favor key sequences that can be generated on any
terminal, i.e. ascii chars (maybe combined with the meta modifier).  C-y is
an ascii char so it is preferred over A-v.

So if you really want to see A-v in the menu, you need to either somehow
hide the C-y binding, or put the info up there explicitly (using
the :key-sequence parameter in the menu-item).

The first option can be done with something like

    (defalias 'hidden-yank 'yank)
    (global-set-key [(control y)] 'hidden-yank)

But the second option is preferable since it allows things like C-h f to
still list *all* the bindings.

> Also, I would like to change the way the keyboard shortcuts appear in the
> menu. Can I redefine a function to do that?

IIRC it's key-description and it's written in C.  Also it's called directly
from C, so if you redefine it in elisp, Emacs will not everywhere use your
redefined version.

> Lastly: how do I change a menu item?
> I know how to add submenus to a menu with easychange.el, but I couldn't
> figure out how to actually change the text of an arbitrary item. Is
> that possible?

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.

        Stefan


reply via email to

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