On Tue, 12 Mar 2013 03:38:09 -0400 ken <gebser@mousecar.com> wrote:
On 03/07/2013 09:14 AM Stephen Berman wrote:
[...] If you want a submenu, then instead of
a command name, the third item in your menu-item list should be a
(variable whose value is a) keymap defining the menu items of the
submenu, e.g., something like the following:
(defun kg-insert-ä ()
(interactive)
(insert "ä"))
(defun kg-insert-Ä ()
(interactive)
(insert "Ä"))
(defvar xascii-menu
(let ((menu (make-sparse-keymap "Insert non-ASCII characters")))
(define-key menu [kg-insert-Ä]
'(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A"))
(define-key menu [kg-insert-ä]
'(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a"))
menu))
(define-key menu-bar-edit-menu [xascii-menu]
`(menu-item "Insert non-ASCII characters" ,xascii-menu))
Steve Berman
Thanks, Steve,
I tried this code and it is definitely progress over mine in that it displays
menu items under the "Insert non-ASCII characters" heading. However, those
non-ASCII characters (e.g., `Ä' and `ä') don't display in the menu under that
heading properly; probably owing to the menu subsystem of the emacs frame not
handling utf-8... or 8-bit characters of any kind.
They display fine in the menu in my Emacs. If you're using a
Unicode-capable Emacs (23 or later), they should display for you too,
unless some setting in your system, or maybe some X setting, is
preventing it.
Secondly, the key combos
(e.g., C-xaA and C-xaa) remain undefined.
The use of :keys in a menu item is only for displaying in the menu the
string corresponding to a key binding that you have defined elsewhere,
either using global-set-key, local-set-key, or, if you only want them to
be used in a specific key map, using define-key.