unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Format av menu keymaps
Date: Mon, 09 Jan 2006 18:10:44 -0500	[thread overview]
Message-ID: <jwv3bjx57ox.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <43C2D976.5050302@student.lu.se> (Lennart Borgman's message of "Mon, 09 Jan 2006 22:45:26 +0100")

> **** I have a menu keymap like this that can be used by itself (which is
>      a good thing):
> (defconst xhtml-help-mode-keymap
>   (let ((map (make-sparse-keymap "Xhtml-Help")))
>     (define-key map [menu-bar xh-help] (cons "Xhtml-Help"
>     (make-sparse-keymap "second")))
>     (define-key map [menu-bar xh-help css-help] '("CSS Help"
>     . xhtml-help-show-css-ref))
>     (define-key map [menu-bar xh-help tag-help] '("Xhtml Tag Help"
>     . xhtml-help-show-tag-ref))
>     map))

So far so good.

> **** However now I decided I want to use that in another submenu in
>      menu-bar. Then I do something like this:

I'm not sure what "use" means here.

>       (when (featurep 'xhtml-help)
>         (let ((menu-bar-entry (cdr (assoc 'menu-bar xhtml-help-mode-keymap))))

Rather than `assoc' you should probably use lookup-key.

>           (when menu-bar-entry
>             (map-keymap
>              (lambda(binding command)
>                (let* ((tit-map (appmenu-get-submenu command))
>                       (subtitle (car tit-map))
>                       (submenu  (cdr tit-map)))
>                  (define-key map
>                    [nxhtml-xhtml-help]
>                    (list 'menu-item
>                          subtitle submenu
>                          :help "XHTML help access"))))
>              menu-bar-entry)

There's something odd in this code snice for each iteration of map-keymap
you end up rebinding the same key with `define-key' so only ther last one
will have an effect.

I assume `map' is some arbitrary keymap to which you want to add the entries
found in xhtml-help-mode-keymap?

Why do you use `appmenu-get-submenu' to destructure the menu-item only to
rebuild it right after.

I'd just do

      (when (featurep 'xhtml-help)
        (let ((menu-bar-entry (lookup-key xhtml-help-mode-keymap [menu-bar])))
          (when menu-bar-entry
            (map-keymap
             (lambda (key command)
               (define-key map
                           (vector (intern (concat "nxhtml-" (symbol-name key))))
                           command))
             menu-bar-entry)
            (define-key map [nxhtml-nxhtml-help-separator] (list 'menu-item
            "--"))

but maybe that's not what you're trying to do.


        Stefan

  reply	other threads:[~2006-01-09 23:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-08 22:27 Format av menu keymaps Lennart Borgman
2006-01-09  2:27 ` Stefan Monnier
2006-01-09 21:45   ` Lennart Borgman
2006-01-09 23:10     ` Stefan Monnier [this message]
2006-01-09 23:57       ` Lennart Borgman
2006-01-10  4:21         ` Stefan Monnier
     [not found]           ` <43C36D10.1050003@student.lu.se>
     [not found]             ` <jwvmzi43xn9.fsf-monnier+emacs@gnu.org>
2006-01-10 17:00               ` Lennart Borgman
2006-01-10 17:40                 ` Stefan Monnier

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=jwv3bjx57ox.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this public inbox

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

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).