From: Bruce Ingalls <bingalls@CUT-this-SPAM-BLOCK.fit-zones.com>
Subject: popup menu code
Date: Thu, 23 Oct 2003 20:27:24 GMT [thread overview]
Message-ID: <MQWlb.30142$pT1.15751@twister.nyc.rr.com> (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)
next reply other threads:[~2003-10-23 20:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 20:27 Bruce Ingalls [this message]
2003-10-23 22:01 ` popup menu code Stefan Monnier
2003-10-24 17:10 ` Bruce Ingalls
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='MQWlb.30142$pT1.15751@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.
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).