unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Bruce Ingalls <bingalls@fit-zones.NO-SPAM.com>
Subject: Re: Example using x-popup-menu needed
Date: Fri, 17 Oct 2003 16:11:16 GMT	[thread overview]
Message-ID: <EwUjb.65175$pv6.1917@twister.nyc.rr.com> (raw)
In-Reply-To: <%aMjb.86442$gv5.44941@fed1read05>

Dave Neubart wrote:
> Can someone give a very short, simple example of  using this function?

Here's an excerpt from <url: http://emacro.sf.net/ > which makes it 
*easy* to create popups, and there's a port to XEmacs there, too.
Unfortunately, it is not the *correct* way, which is to use keymaps.

What is delaying me from doing this the correct way, is that I haven't 
seen any simple keymaps, and I'm not sure, how to deal with commands 
such as "Goto Line" below, which is not bound to a key (but I am about 
to bind to M-g, anyway)

The example below is easy to edit, and gives Emacs a KDE/Gnome look & feel.

;;__________________________________________________________________________
;;;;;;		choose-from-menu
;;From Sandip Chitale <sandipchitale(at)attbi(dot)com>

(defun choose-from-menu (menu-title menu-items)
   "Choose from a list of choices from a popup menu.
See `popup-commands' which calls this"
   (let ((item)
  (item-list))
     (while menu-items
       (setq item (car menu-items))
       (if (consp item)
    (setq item-list (cons (cons (car item) (cdr item) ) item-list))
  (setq item-list (cons (cons item item) item-list)))
       (setq menu-items (cdr menu-items))
       )
     (x-popup-menu t (list menu-title (cons menu-title (nreverse 
item-list))))))


;;__________________________________________________________________________
   (defun right-popup ()
     "Show a popup menu of commands. See also `choose-from-menu'."
     (interactive)
     (eval-expression
      (car
       (read-from-string
        (choose-from-menu
	"Commands"
	(list
	 (cons "Copy                C-insert" "(call-interactively 
'copy-region-as-kill)")
	 (cons "Goto Line"		"(call-interactively 'goto-line)")
	 (cons "Paste/yank        S-insert"	"(yank)")
	 (cons "Redo"			"(redo)")
	 (cons "Search files"		"(call-interactively 'grep)")
	 (cons "Undo                 C-_"	"(undo)")
	 (cons "Word completion M-/"	"(call-interactively 'dabbrev-expand)")
	 ))))))

   (global-set-key [mouse-3] 'right-popup)

  parent reply	other threads:[~2003-10-17 16:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-17  5:38 Example using x-popup-menu needed Dave Neubart
2003-10-17 13:41 ` Barman Brakjoller
2003-10-17 16:11 ` Bruce Ingalls [this message]
2003-10-17 16:32   ` Martin Stemplinger
2003-10-17 18:14     ` Bruce Ingalls
2003-10-17 16:50   ` Ian Zimmerman
2003-10-17 18:11     ` Bruce Ingalls
2003-10-17 20:07       ` Stefan Monnier
2003-10-17 20:07   ` Kevin Rodgers
2003-10-17 21:26     ` Kevin Rodgers
2003-10-17 20:14   ` Stefan Monnier
2003-10-18 13:45     ` Martin Stemplinger
2003-12-02 20:50   ` Kai Grossjohann
2003-12-03 18:29     ` Kevin Rodgers

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='EwUjb.65175$pv6.1917@twister.nyc.rr.com' \
    --to=bingalls@fit-zones.no-spam.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).