From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: creating a sub-menu Date: Tue, 12 Mar 2013 03:38:09 -0400 Message-ID: <513EDB61.9050100@mousecar.com> References: <51367405.8080403@mousecar.com> <876213paa7.fsf@rosalinde.fritz.box> Reply-To: gebser@mousecar.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1363073917 10339 80.91.229.3 (12 Mar 2013 07:38:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Mar 2013 07:38:37 +0000 (UTC) To: Stephen Berman , GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 12 08:39:02 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UFJnV-0001WI-Ps for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Mar 2013 08:38:57 +0100 Original-Received: from localhost ([::1]:38431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJn9-0004Iw-9m for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Mar 2013 03:38:35 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJmx-0004Iq-ND for help-gnu-emacs@gnu.org; Tue, 12 Mar 2013 03:38:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFJmv-0006l1-DQ for help-gnu-emacs@gnu.org; Tue, 12 Mar 2013 03:38:23 -0400 Original-Received: from mout.perfora.net ([74.208.4.194]:63626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJmv-0006kc-6i for help-gnu-emacs@gnu.org; Tue, 12 Mar 2013 03:38:21 -0400 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus4) with ESMTP (Nemesis) id 0MQ2f5-1UAcgy1xsR-005U7E; Tue, 12 Mar 2013 03:38:17 -0400 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 In-Reply-To: <876213paa7.fsf@rosalinde.fritz.box> X-Provags-ID: V02:K0:238CgN3BXRZ85QDEXe+9n8O+paws3QNQQSfJjE9WaBy SDVVv//gtAjGsEZmAyJPoM2lZjQd+EWU8FOOjS/zOKSFX00qP7 AUBShNTGX7jmcb/IKxUdgAx80hmJXxCOTBLWn5K47jQXh5lyof e7hbT+M6cxn3veZ/rKs+cLmfVKmhWKIJmZZ+qAUzcwSPCDhBxD LoHq/QTrshRBHPvmdgIqkDKooFc28Y0jTjpr01obgGsRclcyLK aILEnx1jURhnsa1k3wraHoHs/DK7EH6imfB9SN3s04oIqwNtkn mL7rh+Do1DR8la6FqpBDGrXtODqV1ODRkdIYs6d95W7+tpownK Kn5nG6i5/RpvMK69jLSu4R8F20pvfFz5HF43Awb/S X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 74.208.4.194 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89480 Archived-At: On 03/07/2013 09:14 AM Stephen Berman wrote: > On Tue, 05 Mar 2013 17:39:01 -0500 ken wrote: > >> Trying to create a sub-menu under "Edit". Got part of the way there, but >> still missing something. >> >> (define-key menu-bar-edit-menu [insert-xascii-chars] >> '(menu-item "Insert non-ASCII characters" xascii >> >> (xascii "\C-xaa" "ä" "ä` (ä)" ("ä")) >> (xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä")) >> (xascii "\C-xao" "ö" "ö` (ö)" ("ö")) >> (xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö")) >> (xascii "\C-xau" "ü" "ü` (ü)" ("ü")) >> (xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü")) >> (xascii "\C-xas" "ß" "ß` (ß)" ("ß")) >> (xascii "\C-xa<" "«" "«` («)" ("«")) >> (xascii "\C-xa>" "»" "»` (»)" ("»")))) >> >> Above yields error: >> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii) > > When I evaluate it in a recent Emacs build from the bzr trunk, I get no > error. But instead of adding a submenu to the Edit menu, it just adds > the entry "Insert non-ASCII characters" (when I click on that entry, it > tries to execute the xascii command, and since I have that, I get "Lisp > error: (void-function xascii)"). If you want a submenu, then instead of > a command name, the third item in your menu-item list should be a > (variable whose value is a) keymap defining the menu items of the > submenu, e.g., something like the following: > > (defun kg-insert-ä () > (interactive) > (insert "ä")) > > (defun kg-insert-Ä () > (interactive) > (insert "Ä")) > > (defvar xascii-menu > (let ((menu (make-sparse-keymap "Insert non-ASCII characters"))) > (define-key menu [kg-insert-Ä] > '(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A")) > (define-key menu [kg-insert-ä] > '(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a")) > menu)) > > (define-key menu-bar-edit-menu [xascii-menu] > `(menu-item "Insert non-ASCII characters" ,xascii-menu)) > > Steve Berman Thanks, Steve, I tried this code and it is definitely progress over mine in that it displays menu items under the "Insert non-ASCII characters" heading. However, those non-ASCII characters (e.g., `Ä' and `ä') don't display in the menu under that heading properly; probably owing to the menu subsystem of the emacs frame not handling utf-8... or 8-bit characters of any kind. Secondly, the key combos (e.g., C-xaA and C-xaa) remain undefined. But you've advanced the code over what I had and I appreciate that very much. The bit of explanation you provide is also helpful. Together with the bits in the Elisp Manual and other sources on the web, the total picture on adding a sub-menu into an existing menu heading is starting to come together, though still I'm far from being able to articulate it the way I want and would need in order to be helpful to anyone else. So I'll work on it more in whatever spare moments I have. I'm sure I'll get it eventually. Thanks again, ken