[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp question
From: |
Stefan Monnier |
Subject: |
Re: elisp question |
Date: |
Thu, 01 Dec 2005 16:00:09 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
>> (let ((files (directory-files "foo/bar/kaya" 'full "[^.]\\|...")))
>> (pop-to-buffer (find-file-noselect (nth (random (length files)) files))))
> That looks simpler than what I was thinking, although I'll have to go
> through it argument by argument to make sure I understand it. I was
> expecting to have to count the number of files in the directory, then
(length files) counts the number of files.
> use that number as the limit to (random),
Indeed, that's what it does.
> and somehow be able to make (find-files) use the result from (random) as
> the name of the file to be read into the buffer.
Indeed (nth ... files) selects the randomly chosen file name from the list
of file names.
Stefan
Re: elisp question, Tim McNamara, 2005/12/01