[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example using x-popup-menu needed
From: |
Stefan Monnier |
Subject: |
Re: Example using x-popup-menu needed |
Date: |
Fri, 17 Oct 2003 20:14:50 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> (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))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
why do such unnecessary copying ?
> (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))))))
You mean (x-popup-menu
t (list menu-title
(cons menu-title
(mapcar (lambda (item)
(if (consp item) item
(cons item item)))
item-list))))
> (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)")
> ))))))
You mean
(call-interactively
(choose-from-menu "Commands"
'(("Copy C-insert" . copy-region-as-kill)
("Goto Line" . goto-line)
("Paste/Yank S-insert" . yank)
("Redo" . redo)
("Search Files" . grep)
("Undo C-_" . undo)
("Word Completion M-/" . dabbrev-expand))))
> (global-set-key [mouse-3] 'right-popup)
If you define `right-popup' as a menu keymap, you'll save yourself
the trouble of calling the commands and you'll get the hotkeys for free.
Stefan