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: popup menu code Date: Thu, 23 Oct 2003 20:27:24 GMT Organization: Road Runner - NYC Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: 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 1066941116 23866 80.91.224.253 (23 Oct 2003 20:31:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 23 Oct 2003 20:31:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 23 22:31:52 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 1ACm7b-0000Fp-00 for ; Thu, 23 Oct 2003 22:31:51 +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 1ACm6Z-0005cA-8I for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Oct 2003 16:30:47 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!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 (X11; U; Linux i586; en-US; rv:1.4) Gecko/20030701 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-NNTP-Posting-Host: 24.168.132.65 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.nyc.rr.com 1066940844 24.168.132.65 (Thu, 23 Oct 2003 16:27:24 EDT) Original-NNTP-Posting-Date: Thu, 23 Oct 2003 16:27:24 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:117567 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:13499 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13499 ;;Thanks to your help, I made the following improvements to my popup menu. ;;However, because I must put when(mark-active) clauses in my code, this ;;prevents the keybindings from showing up. ;;Any way around this? ;;There are multiple keybindings to Copy. I'd rather not see [f17] (from memory) ;;Are hints available to show C-Ins, M-w or C-c, if cua.el is loaded? ;;Also note that this code does not work under XEmacs. ;;Finally, I suspect that my code for menu separators is not the best (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 ;;Unfortunately, keybinding is not to when() clause, which must necessarily ;;surround the function (define-key menu [kill-region] (cons "Cut" '(when (and mark-active (not buffer-read-only) (call-interactively 'kill-region))))) (define-key menu [yank] (cons "Paste" '(when (and mark-active (not buffer-read-only) 'yank)))) (define-key menu [copy-region-as-kill] (cons "Copy" '(when mark-active 'copy-region-as-kill))) ;; (define-key menu [-] (cons "-" 'nil)) ;separator ;; (define-key menu [emacro-help] ;; (cons (concat "EMacro v" emacro-version) 'emacro-help)) menu)) (defun right-popup () ;event "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)