all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruce Ingalls <bingalls@CUT-this-SPAM-BLOCK.fit-zones.com>
Subject: Re: popup menu code
Date: Fri, 24 Oct 2003 17:10:49 GMT	[thread overview]
Message-ID: <t2dmb.9823$ri.2819619@twister.nyc.rr.com> (raw)
In-Reply-To: <jwvd6cnvcod.fsf-monnier+gnu.emacs.help@vor.iro.umontreal.ca>

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)

  reply	other threads:[~2003-10-24 17:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-23 20:27 popup menu code Bruce Ingalls
2003-10-23 22:01 ` Stefan Monnier
2003-10-24 17:10   ` Bruce Ingalls [this message]
2003-10-24 17:32     ` Stefan Monnier
2003-10-23 22:14 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='t2dmb.9823$ri.2819619@twister.nyc.rr.com' \
    --to=bingalls@cut-this-spam-block.fit-zones.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.