emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 5110c95: Add commands for controlling MPD modes


From: Mark Oteiza
Subject: [Emacs-diffs] master 5110c95: Add commands for controlling MPD modes
Date: Thu, 15 Oct 2015 16:34:51 +0000

branch: master
commit 5110c952069e593cb95593f7b3c41d67cb4559d6
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    Add commands for controlling MPD modes
    
    * lisp/mpc.el (mpc-cmd-consume, mpc-cmd-random, mpc-cmd-repeat)
    (mpc-cmd-single): New functions.
    (mpc-consume, mpc-repeat, mpc-single, mpc-shuffle): New commands.
    (mpc-mode-menu): Add new commands as menu items.
---
 lisp/mpc.el |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index 55123ef..8cbea4f 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -796,6 +796,22 @@ The songs are returned as alists."
   ;; (setq mpc-queue-back nil mpc-queue nil)
   )
 
+(defun mpc-cmd-consume (&optional arg)
+  "Set consume mode state."
+  (mpc-proc-cmd (list "consume" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-random (&optional arg)
+  "Set random (shuffle) mode state."
+  (mpc-proc-cmd (list "random" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-repeat (&optional arg)
+  "Set repeat mode state."
+  (mpc-proc-cmd (list "repeat" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-single (&optional arg)
+  "Set single mode state."
+  (mpc-proc-cmd (list "single" arg) #'mpc-status-refresh))
+
 (defun mpc-cmd-pause (&optional arg callback)
   "Pause or resume playback of the queue of songs."
   (let ((cb callback))
@@ -1121,6 +1137,16 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
     ["Play/Pause" mpc-toggle-play]
     ["Next Track" mpc-next]
     ["Previous Track" mpc-prev]
+    "--"
+    ["Repeat Playlist" mpc-repeat :style toggle
+     :selected (member '(repeat . "1") mpc-status)]
+    ["Shuffle Playlist" mpc-shuffle :style toggle
+     :selected (member '(random . "1") mpc-status)]
+    ["Repeat Single Track" mpc-single :style toggle
+     :selected (member '(single . "1") mpc-status)]
+    ["Consume Mode" mpc-consume :style toggle
+     :selected (member '(consume . "1") mpc-status)]
+    "--"
     ["Add new browser" mpc-tagbrowser]
     ["Update DB" mpc-update]
     ["Quit" mpc-quit]))
@@ -2336,6 +2362,30 @@ This is used so that they can be compared with `eq', 
which is needed for
     (mpc-status-stop)
     (if proc (delete-process proc))))
 
+(defun mpc-consume ()
+  "Toggle consume mode: removing played songs from the playlist."
+  (interactive)
+  (mpc-cmd-consume
+   (if (string= "0" (cdr (assq 'consume (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-repeat ()
+  "Toggle repeat mode."
+  (interactive)
+  (mpc-cmd-repeat
+   (if (string= "0" (cdr (assq 'repeat (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-single ()
+  "Toggle single mode."
+  (interactive)
+  (mpc-cmd-single
+   (if (string= "0" (cdr (assq 'single (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-shuffle ()
+  "Toggle shuffling of the playlist (random mode)."
+  (interactive)
+  (mpc-cmd-random
+   (if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0")))
+
 (defun mpc-stop ()
   "Stop playing the current queue of songs."
   (interactive)



reply via email to

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