[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: |
Wed, 02 Jul 2003 09:30:57 -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:
On Mon Jun 30, Kevin Rodgers disturbed my nap when he said:
(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.
You could use a regexp like "\\`[^.]+\\'" to match file names without any dots.
You could also delete the directories from the list:
(require 'cl)
...
(delete-if 'file-directory-p (directory-files ...))
What's the escaped ' for in dir-files regexp - I don't see it (Info)?
Look closer:
| `\''
| matches the empty string, but only at the end of the buffer or
| string being matched against.
"\\'" is preferred, instead of "$".
Thanks again - much appreciated!
No problem!
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>