unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* popup menu code
@ 2003-10-23 20:27 Bruce Ingalls
  2003-10-23 22:01 ` Stefan Monnier
  2003-10-23 22:14 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Bruce Ingalls @ 2003-10-23 20:27 UTC (permalink / raw)


;;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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-24 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-23 20:27 popup menu code Bruce Ingalls
2003-10-23 22:01 ` Stefan Monnier
2003-10-24 17:10   ` Bruce Ingalls
2003-10-24 17:32     ` Stefan Monnier
2003-10-23 22:14 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).