unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: ken <gebser@mousecar.com>
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: creating a sub-menu
Date: Tue, 12 Mar 2013 23:22:46 +0100	[thread overview]
Message-ID: <87d2v4uukp.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: <513EDB61.9050100@mousecar.com> (ken's message of "Tue, 12 Mar 2013 03:38:09 -0400")

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.

> But you've advanced the code over what I had and I appreciate that very much.
> The bit of explanation you provide is also helpful.  Together with the bits in
> the Elisp Manual and other sources on the web, the total picture on adding a
> sub-menu into an existing menu heading is starting to come together, though
> still I'm far from being able to articulate it the way I want and would need
> in order to be helpful to anyone else.  So I'll work on it more in whatever
> spare moments I have. I'm sure I'll get it eventually.

Good luck!

Steve Berman



  reply	other threads:[~2013-03-12 22:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-05 22:39 creating a sub-menu ken
2013-03-07 14:14 ` Stephen Berman
2013-03-12  7:38   ` ken
2013-03-12 22:22     ` Stephen Berman [this message]
2013-03-12 23:09       ` ken
     [not found] <mailman.21496.1362523165.855.help-gnu-emacs@gnu.org>
2013-03-06  1:42 ` Joost Kremers
2013-03-06 11:44   ` ken
     [not found]   ` <mailman.21539.1362570279.855.help-gnu-emacs@gnu.org>
2013-03-06 20:55     ` Joost Kremers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d2v4uukp.fsf@rosalinde.fritz.box \
    --to=stephen.berman@gmx.net \
    --cc=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).