From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Format av menu keymaps Date: Tue, 10 Jan 2006 00:57:47 +0100 Message-ID: <43C2F87B.1030401@student.lu.se> References: <43C191E2.6030206@student.lu.se> <87r77ikuia.fsf-monnier+emacs@gnu.org> <43C2D976.5050302@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1136851113 18492 80.91.229.2 (9 Jan 2006 23:58:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Jan 2006 23:58:33 +0000 (UTC) Cc: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 10 00:58:31 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ew6uE-0006QN-NA for ged-emacs-devel@m.gmane.org; Tue, 10 Jan 2006 00:58:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ew6wB-0005EP-C6 for ged-emacs-devel@m.gmane.org; Mon, 09 Jan 2006 19:00:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ew6ve-0005E5-I5 for emacs-devel@gnu.org; Mon, 09 Jan 2006 18:59:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ew6vd-0005DF-1V for emacs-devel@gnu.org; Mon, 09 Jan 2006 18:59:58 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ew6vc-0005D4-Ro for emacs-devel@gnu.org; Mon, 09 Jan 2006 18:59:56 -0500 Original-Received: from [81.228.8.83] (helo=pne-smtpout1-sn2.hy.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ew6xz-0001nJ-1k for emacs-devel@gnu.org; Mon, 09 Jan 2006 19:02:23 -0500 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.069.1) id 43C290FB0001AAEA; Tue, 10 Jan 2006 00:57:47 +0100 User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en Original-To: Stefan Monnier In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48885 Archived-At: 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.