From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Nordl=F6w?= Newsgroups: gmane.emacs.help Subject: Auto-Generation of Sub-Menu Items (Keys) from a list of lists Date: Wed, 17 Sep 2008 03:41:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2b204852-9a90-49ea-b3e8-ac2e4a3be5e6@2g2000hsn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1221652042 20133 80.91.229.12 (17 Sep 2008 11:47:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Sep 2008 11:47:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 17 13:48:19 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KfvW6-0005xh-Mx for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Sep 2008 13:48:19 +0200 Original-Received: from localhost ([127.0.0.1]:36144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfvV5-0007qu-Os for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Sep 2008 07:47:15 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!2g2000hsn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 82 Original-NNTP-Posting-Host: 150.227.15.253 Original-X-Trace: posting.google.com 1221648062 30426 127.0.0.1 (17 Sep 2008 10:41:02 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 17 Sep 2008 10:41:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 2g2000hsn.googlegroups.com; posting-host=150.227.15.253; posting-account=ytJKAgoAAAA1tg4ScoRszebXiIldA5vg User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; sv-SE; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 netcache (NetCache NetApp/6.1.1RC1) Original-Xref: news.stanford.edu gnu.emacs.help:162382 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57725 Archived-At: I am trying to automatically create a Sub-menu to "C++"-menu from the list c++-iostream-objects in the following way: (defvar c++-iostream-objects '( ("cin" [cin] "Standard input stream." 'object) ("cout" [cout] "Standard output stream." 'object) ("cerr" [cerr] "Standard output stream for errors." 'object) ("clog" [clog] "Standard output stream for logging." 'object) ) "List of C++ IOstream Objects.") (defun generate-keymap-menu (keymap-menu-name insert-prefix alist) (let ((m (make-sparse-keymap keymap-menu-name))) (dolist (elm (reverse alist)) (let* ((str (concat insert-prefix (elt elm 0))) (key (elt elm 1)) (doc (elt elm 2)) ) (define-key m key `(menu-item ,str '(lambda () (interactive) (insert ,str)) :help ,doc)))) m)) (defvar c++-iostream-objects-menu) (setq c++-iostream-objects-menu (generate-keymap-menu "IOstream Objects" "std::" c++-iostream- objects)) (add-hook 'c++-mode-hook '(lambda () (define-key-after c-c++-menu [iostream-objects] (cons "IOstream Objects" c++-iostream-objects- menu) t)) t) The value of c++-iostream-objects-menu after evaluating the above is: (keymap (cin menu-item "std::cin" '(lambda nil (interactive) (insert "std::cin")) :help "Standard input stream.") (cout menu-item "std::cout" '(lambda nil (interactive) (insert "std::cout")) :help "Standard output stream.") (cerr menu-item "std::cerr" '(lambda nil (interactive) (insert "std::cerr")) :help "Standard output stream for errors.") (clog menu-item "std::clog" '(lambda nil (interactive) (insert "std::clog")) :help "Standard output stream for logging.") "IOstream Objects") and the sub-menu elements gets created but when I press on one of them I get the error: Debugger entered--Lisp error: (wrong-type-argument commandp (quote (lambda nil (interactive) (insert "std::cin")))) call-interactively((quote (lambda nil (interactive) (insert "std::cin"))) nil nil) This is really strange since the evaluation of (call-interactively (quote (lambda nil (interactive) (insert "std::cin")))) works correctly and (commandp (quote (lambda nil (interactive) (insert "std::cin")))) evaluates to t. What on earth have I missed? This nut is really hard to crack! Many thanks in advance, Nordl=F6w