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: popup menu code Date: Fri, 24 Oct 2003 17:10:49 GMT Organization: Road Runner - NYC Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: 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 1067015802 27071 80.91.224.253 (24 Oct 2003 17:16:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 24 Oct 2003 17:16:42 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 24 19:16:40 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 1AD5YG-0003RG-00 for ; Fri, 24 Oct 2003 19:16:40 +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 1AD5YF-0000yf-TQ for geh-help-gnu-emacs@m.gmane.org; Fri, 24 Oct 2003 13:16:39 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!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!not-for-mail User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.5) Gecko/20031017 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 58 Original-NNTP-Posting-Host: 24.168.132.201 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.nyc.rr.com 1067015449 24.168.132.201 (Fri, 24 Oct 2003 13:10:49 EDT) Original-NNTP-Posting-Date: Fri, 24 Oct 2003 13:10:49 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:117587 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:13519 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13519 Stefan Monnier wrote: > Does this work? I know it does in easy-menus,... I could not figure out, how to get easy-menu working for popups. Having XEmacs portable code would be nice. > Better use an `activate' property. Check out the elisp documentation. > More specifically, look for `menu-item' in the index. I could not find activate nor menu-item from C-h a apropos. I was a little overwhelmed, looking at advise's ad-activate > IIRC, you can get rid of right-popup and just do > (global-set-key [mouse-3] right-popup-menu) did not work for me. However, thanks to your advice, I am happy with this reworked, working code at bottom. The only annoyance, is that I am picking up f16 & f20 as the (sun keyboard) keybindings for cut and copy, likely from cua.el ;;__________________________________________________________________________ ;;;;;; Customize A Popup Menu (defun menu-copy() "Wrapper to call `copy-region-as-kill' from menu." (interactive) (when mark-active 'copy-region-as-kill)) (defun menu-cut() "Wrapper to `call kill-region' from menu." (interactive) (when (and mark-active (not buffer-read-only) (call-interactively 'kill-region)))) (defun menu-paste() "Wrapper to call `yank' from menu." (interactive) (when (not buffer-read-only) (call-interactively 'yank))) (defvar right-popup-menu (let ((menu (make-sparse-keymap "Commands"))) (define-key menu [dabbrev-expand] (cons "Complete word" 'dabbrev-expand)) (define-key menu [undo] (cons "Undo" 'undo)) (define-key menu [redo] (cons "Redo" 'redo)) (define-key menu [--] (cons "--" 'nil)) ;separator (define-key menu [menu-paste] (cons "Paste" 'yank)) (define-key menu [menu-copy] (cons "Copy" 'copy-region-as-kill)) (define-key menu [menu-cut] (cons "Cut" 'kill-region)) (define-key menu [-] (cons "-" 'nil)) ;separator (define-key menu [emacro-help] (cons (concat "EMacro v" emacro-version) 'emacro-help)) menu)) (defun right-popup() "Run the command selected from `right-popup-menu'." (interactive) (call-interactively (or (car (x-popup-menu t right-popup-menu)) 'ignore))) (global-set-key [mouse-3] 'right-popup)