|
From: | Kevin Rodgers |
Subject: | Re: elisp question |
Date: | Fri, 02 Dec 2005 10:51:54 -0700 |
User-agent: | Mozilla Thunderbird 0.9 (X11/20041105) |
Stefan Monnier wrote:
(pop-to-buffer (find-file-noselect (expand-file-name (number-to-string (random N)) "foo/bar/kaya"))) This assumes the file names go from 0 to N-1. You could also do (let ((files (directory-files "foo/bar/kaya" 'full "[^.]\\|..."))) (pop-to-buffer (find-file-noselect (nth (random (length files)) files)))) and just select any random file in the directory, without any assumption on the file names used.
Since the original code already popped to the *Dharma* buffer, I think (erase-buffer) (insert-file-contents ...) would be better than (pop-to-buffer (find-file-noselect ...)) -- Kevin Rodgers
[Prev in Thread] | Current Thread | [Next in Thread] |