emacs-devel
[Top][All Lists]
Advanced

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

Re: Format av menu keymaps


From: Lennart Borgman
Subject: Re: Format av menu keymaps
Date: Tue, 10 Jan 2006 00:57:47 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

Stefan Monnier wrote:

     (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.
Thanks.

         (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.
Yes, it is odd. I am using map-keymap just to get the 'command'. (There is only one entry in menu-bar-entry.) Is there another way?

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

Why do you use `appmenu-get-submenu' to destructure the menu-item only to
rebuild it right after.
The submenu I gave is just an example. I do not know the format of the submenu normally. `appmenu-get-submenu' (see previous message) handles those two formats for a submenu that I have seen. There may be more, but I do not know. Are there more?

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.
It is not exactly what I want to do, but some of the syntax I can surely use, thanks.




reply via email to

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