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 18:00:13 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

Stefan Monnier wrote:


Do you mean something like this should work:

         (let ((menu-bar-entry (lookup-key emacs-lisp-mode-map
         [menu-bar])))
           (when menu-bar-entry
             (setq some-major t)
             (define-key map [appmenu-major] menu-bar-entry)))

No, I men something like what I sent before:

           (map-keymap
            (lambda (key command)
              (define-key map
                          (vector (intern (concat "nxhtml-" (symbol-name key))))
                          command))
            menu-bar-entry)

Note how the `command' is left untouched rather than go through
appmenu-get-submenu and then be rebuilt with menu-item.
Thanks very much, this works perfectly, using the value returned from lookup-key for menu-bar-entry. I thought I tried something very similar, but obviously I did not. And now the code also handles the keys with several entries in menu-bar which I just overlooked.

Lesson one is that I have learned to use lookup-key (instead of fumbling with assoc). This gives less complexity and less opportunities for mistakes. And doing it the way above (without using appmenu-get-submenu) I obviously do not have to know the internal format of the submenu. So there was really no reason to ask here on this list. Sorry for disturbing here then.

But I wonder why you prefer to use

   (vector (intern (concat "appmenu-major-" (symbol-name key))))

instead of

   (read (concat "[appmenu-major-" (symbol-name key) "]"))

Just a matter of taste or? You mentioned some time ago that it normally was a mistake to use (read ...).




reply via email to

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