[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating a menu/pop-up?
From: |
Kevin Rodgers |
Subject: |
Re: Creating a menu/pop-up? |
Date: |
Mon, 30 Jun 2003 10:48:22 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 |
Mike Ballard wrote:
Anyone have an idea or two for an elisp neophyte so that I can create a
pop-up showing my list of text files such that clicking on one of the
files runs it under steno?
How's this for a start:
(defun mouse-steno-popup (e)
"Pop up a menu of *.txt files in the ~ directory. E is a mouse event."
(interactive "e")
(let ((steno-menu (steno-popup-menu))) ; keymap
(call-interactively (lookup-key steno-menu
(vector (x-popup-menu e steno-menu))))))
(global-set-key [S-down-mouse-3] 'mouse-steno-popup)
(defun steno-popup-menu ()
"Return a menu keymap mapping each ~/*.txt file to \\[steno-command]."
(let ((menu (make-sparse-keymap "Steno Files"))
(files (nreverse (directory-files "~" nil "\\.txt\\'"))))
(while files
(define-key menu (vector (intern (car files)))
(cons (car files)
`(lambda ()
,(format "Run \\[steno-command] on \"%s\"." (car files))
(interactive)
(steno-command ,(car files)))))
(setq files (cdr files)))
menu))
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>