[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
popup menu code
From: |
Bruce Ingalls |
Subject: |
popup menu code |
Date: |
Thu, 23 Oct 2003 20:27:24 GMT |
User-agent: |
Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.4) Gecko/20030701 |
;;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)
- popup menu code,
Bruce Ingalls <=