From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Bruce Ingalls Newsgroups: gmane.emacs.help Subject: Re: Example using x-popup-menu needed Date: Fri, 17 Oct 2003 16:11:16 GMT Organization: Road Runner - NYC Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <%aMjb.86442$gv5.44941@fed1read05> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1066407821 21036 80.91.224.253 (17 Oct 2003 16:23:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Oct 2003 16:23:41 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 17 18:23:39 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AAXO7-0005lR-00 for ; Fri, 17 Oct 2003 18:23:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AAXNW-0004aL-9W for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Oct 2003 12:23:02 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!cyclone.bc.net!newsfeed.telusplanet.net!newsfeed.telus.net!news3.optonline.net!cyclone.rdc-nyc.rr.com!news-out.nyc.rr.com!twister.nyc.rr.com.POSTED!53ab2750!not-for-mail User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030723 Thunderbird/0.1 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help In-Reply-To: <%aMjb.86442$gv5.44941@fed1read05> Original-Lines: 56 Original-NNTP-Posting-Host: 24.168.133.21 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.nyc.rr.com 1066407076 24.168.133.21 (Fri, 17 Oct 2003 12:11:16 EDT) Original-NNTP-Posting-Date: Fri, 17 Oct 2003 12:11:16 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:117366 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:13296 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13296 Dave Neubart wrote: > Can someone give a very short, simple example of using this function? Here's an excerpt from which makes it *easy* to create popups, and there's a port to XEmacs there, too. Unfortunately, it is not the *correct* way, which is to use keymaps. What is delaying me from doing this the correct way, is that I haven't seen any simple keymaps, and I'm not sure, how to deal with commands such as "Goto Line" below, which is not bound to a key (but I am about to bind to M-g, anyway) The example below is easy to edit, and gives Emacs a KDE/Gnome look & feel. ;;__________________________________________________________________________ ;;;;;; choose-from-menu ;;From Sandip Chitale (defun choose-from-menu (menu-title menu-items) "Choose from a list of choices from a popup menu. See `popup-commands' which calls this" (let ((item) (item-list)) (while menu-items (setq item (car menu-items)) (if (consp item) (setq item-list (cons (cons (car item) (cdr item) ) item-list)) (setq item-list (cons (cons item item) item-list))) (setq menu-items (cdr menu-items)) ) (x-popup-menu t (list menu-title (cons menu-title (nreverse item-list)))))) ;;__________________________________________________________________________ (defun right-popup () "Show a popup menu of commands. See also `choose-from-menu'." (interactive) (eval-expression (car (read-from-string (choose-from-menu "Commands" (list (cons "Copy C-insert" "(call-interactively 'copy-region-as-kill)") (cons "Goto Line" "(call-interactively 'goto-line)") (cons "Paste/yank S-insert" "(yank)") (cons "Redo" "(redo)") (cons "Search files" "(call-interactively 'grep)") (cons "Undo C-_" "(undo)") (cons "Word completion M-/" "(call-interactively 'dabbrev-expand)") )))))) (global-set-key [mouse-3] 'right-popup)