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

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

Re: elisp question


From: Tim McNamara
Subject: Re: elisp question
Date: Thu, 01 Dec 2005 19:02:55 -0600
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> (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.

Well, there it is.  It works well in early testing.  Sheesh, it'd have
taken me a month to work up something like that!  Thanks lots.  Now I
get to go through the elisp manual and learn from the example- and to
populate the data directory with files.


reply via email to

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