diff options
author | forcer <forcer> | 2005-09-12 23:36:00 +0000 |
---|---|---|
committer | forcer <mwolson@gnu.org> | 2005-09-12 23:36:00 +0000 |
commit | c94c41fd6b9618e4a6422266f9e712753a8c199c (patch) | |
tree | 721663c31507398b78f25a9ef378b2524149a567 | |
parent | b75e294ed74af4e6a893af7400604e9967f493eb (diff) |
Added `emms-random[_\c3_]' (idea by twb)
darcs-hash:20050912233602-2189f-15c33eafc9d4c587065046a26762fa07359aee0d.gz
-rw-r--r-- | emms.el | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -250,6 +250,14 @@ This is a good function to put in `emms-player-finished-hook'." (emms-playlist-select-previous) (emms-start)) +(defun emms-random () + "Jump to a random track." + (interactive) + (when emms-player-playing-p + (emms-stop)) + (emms-playlist-select-random) + (emms-start)) + (defun emms-pause () "Pause the current player." (interactive) @@ -572,6 +580,32 @@ used, and the contents removed." (error (error "No previous track in playlist")))))) +(defun emms-playlist-select-random () + "Select a random track in the playlist." + (with-current-emms-playlist + ;; FIXME: This is rather inefficient. + (save-excursion + (let ((track-indices nil) + (donep nil)) + (condition-case nil + (progn + (emms-playlist-first) + (setq track-indices (cons (point) + track-indices))) + (error + (setq donep t))) + (while (not donep) + (condition-case nil + (progn + (emms-playlist-next) + (setq track-indices (cons (point) + track-indices))) + (error + (setq donep t)))) + (setq track-indices (vconcat track-indices)) + (emms-playlist-select (aref track-indices + (random (length track-indices)))))))) + (defun emms-playlist-select-first () "Select the first track in the playlist." (with-current-emms-playlist |