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: Mon, 09 Jan 2006 22:45:26 +0100 Message-ID: <43C2D976.5050302@student.lu.se> References: <43C191E2.6030206@student.lu.se> <87r77ikuia.fsf-monnier+emacs@gnu.org> 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 1136844251 29863 80.91.229.2 (9 Jan 2006 22:04:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Jan 2006 22:04:11 +0000 (UTC) Cc: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 09 23:04:06 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 1Ew572-0000zu-SI for ged-emacs-devel@m.gmane.org; Mon, 09 Jan 2006 23:03:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ew4rp-0002eT-Py for ged-emacs-devel@m.gmane.org; Mon, 09 Jan 2006 16:47:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ew4rf-0002eA-1y for emacs-devel@gnu.org; Mon, 09 Jan 2006 16:47:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ew4rd-0002dl-Gm for emacs-devel@gnu.org; Mon, 09 Jan 2006 16:47:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ew4rd-0002db-CM for emacs-devel@gnu.org; Mon, 09 Jan 2006 16:47:41 -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 1Ew4ty-00007v-Jt for emacs-devel@gnu.org; Mon, 09 Jan 2006 16:50:06 -0500 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.069.1) id 43C290FB000163CD; Mon, 9 Jan 2006 22:45:27 +0100 User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en Original-To: Stefan Monnier In-Reply-To: <87r77ikuia.fsf-monnier+emacs@gnu.org> 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:48882 Archived-At: Stefan Monnier wrote: >>I am loooking for the format of a menu keymap. There seem to be several >>different formats that are possible for a submenu, but I can not find where >>these are described. Are there any functions to check if an entry in >>a keymap list is a submenu? >> >> > >Any keymap is potentially a menu. It depends on whether you use it like one >or not (e.g. if you pass it to x-popup-menu or bind it to some mouse event). >So I think the question is wrongly phrased. Could you give us some context >and more concrete details of what you're trying to do? > I am trying to "reuse submenu keymaps". Let us say I have defined a little minor mode that adds a submenu to the menu-bar. I may later want to use this submenu in another place, say in another submenu on the menu-bar. I may also want to use it in a popup menu. Is this clear enough or does it just sound crazy? Maybe an example can help: **** 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)) **** However now I decided I want to use that in another submenu in menu-bar. Then I do something like this: (when (featurep 'xhtml-help) (let ((menu-bar-entry (cdr (assoc 'menu-bar xhtml-help-mode-keymap)))) (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) (define-key map [nxhtml-nxhtml-help-separator] (list 'menu-item "--")) ***** Where this little function tries to get the submenu: (defun appmenu-get-submenu(menu-command) (let (subtitle submenumap) (if (eq 'menu-item (car menu-command)) (progn (setq subtitle (cadr menu-command)) (setq submenumap (caddr menu-command))) (setq subtitle (car menu-command)) (setq submenumap (cdr menu-command))) (unless (keymapp submenumap) (error "submenu not a keymap=%s" submenu)) (cons subtitle submenumap))) There are two things I do not really like, appmenu-get-submenu and the use of map-keymap. I do not know what to do instead. For appmenu-get-submenu I would like at least some documentation for how to write this. Even better would be defun in Emacs for something like it. Since we are close to a release (I hope) I really just wanted to say that it seems to me like documentation is missing. And if the code looks wrong then of course I would like some hints.