help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a menu/pop-up?


From: Mike Ballard
Subject: Re: Creating a menu/pop-up?
Date: Wed, 02 Jul 2003 02:33:48 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

On Mon Jun 30, Kevin Rodgers disturbed my nap when he said:

> 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))
> 

Outstanding!  Thanks so much - it gives me exactly what I was looking for.

I got the steno cmd in, and my text files have no ext and using nil
w/dir-files includes . and .. in pop-up, but I'll get it.

What's the escaped ' for in dir-files regexp - I don't see it (Info)?

Thanks again - much appreciated!

Mike
-- 

mike.ballard--at--earthlink.net

  "Play an accordion, go to jail.  It's the law!"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]