Hello,

I've attached a small patch which adds `emms-toggle-random-playlist'. It
sets `emms-player-next-function' to either `emms-next-noerror' or
`emms-random'.

From 6ac585ff8316524423fb76ed1ca0a525f0b78694 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= <[email protected]>
Date: Fri, 10 May 2013 12:00:14 +0200
Subject: [PATCH] lisp/emms.el: New command to play the tracks randomly

* lisp/emms.el (emms-random-playlist): An option to determine whether the
tracks are played randomly or sequentially.
(emms-toggle-random-playlist): Trigger the previous option and set
`emms-play-next-function' accordingly.
---
 lisp/emms.el |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lisp/emms.el b/lisp/emms.el
index c9c4123..81bd80c 100644
--- a/lisp/emms.el
+++ b/lisp/emms.el
@@ -81,6 +81,12 @@ If non-nil, EMMS will wrap back to the first track when that happens."
   :group 'emms
   :type 'boolean)
 
+(defcustom emms-random-playlist nil
+  "*Non-nil means that tracks are played randomly. If nil, tracks
+are played sequentially."
+  :group 'emms
+  :type 'boolean)
+
 (defcustom emms-repeat-track nil
   "Non-nil, playback will repeat current track.  If nil, EMMS will play
 track by track normally."
@@ -487,6 +493,17 @@ This uses `emms-playlist-uniq-function'."
     (save-excursion
       (funcall emms-playlist-uniq-function))))
 
+(defun emms-toggle-random-playlist ()
+  "Toggle whether emms plays the tracks randomly or sequentially.
+See `emms-random-playlist'."
+  (interactive)
+  (setq emms-random-playlist (not emms-random-playlist))
+  (if emms-random-playlist
+      (progn (setq emms-player-next-function 'emms-random)
+             (message "Will play the tracks randomly."))
+    (setq emms-play-next-function 'emms-next-noerror)
+    (message "Will play the tracks sequentially.")))
+
 (defun emms-toggle-repeat-playlist ()
   "Toggle whether emms repeats the playlist after it is done.
 See `emms-repeat-playlist'."
-- 
1.7.10.4

-- 
Daimrod/Greg

Attachment: pgpuQKeOMHJgG.pgp
Description: PGP signature

_______________________________________________
Emms-help mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/emms-help

Reply via email to