]> code.delx.au - gnu-emacs/blobdiff - lisp/mpc.el
Remove duplicate binding
[gnu-emacs] / lisp / mpc.el
index 8cbea4fbbbfc3fb68b0d9760124a0f1d300a63eb..aa7fee6adb61ea38069057b0e668f86623a2cfc8 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mpc.el --- A client for the Music Player Daemon   -*- lexical-binding: t -*-
 
-;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; Keywords: multimedia
@@ -265,10 +265,7 @@ defaults to 6600 and HOST defaults to localhost."
       (let ((v (match-string 3 host)))
         (setq host (match-string 2 host))
         (when (and (stringp v) (not (string= "" v)))
-          (setq port
-                (if (string-match "[^[:digit:]]" v)
-                    (string-to-number v)
-                  v)))))
+          (setq port v))))
     (when (file-name-absolute-p host)
       ;; Expand file name because `file-name-absolute-p'
       ;; considers paths beginning with "~" as absolute
@@ -826,6 +823,9 @@ The songs are returned as alists."
   (mpc-proc-cmd "play")
   (mpc-status-refresh))
 
+(defun mpc-cmd-seekcur (time)
+  (mpc-proc-cmd (list "seekcur" time) #'mpc-status-refresh))
+
 (defun mpc-cmd-add (files &optional playlist)
   "Add the songs FILES to PLAYLIST.
 If PLAYLIST is t or nil or missing, use the main playlist."
@@ -1026,12 +1026,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
                                                (substring time (match-end 0))
                                              time)))))
                     (`Cover
-                     (let ((dir (file-name-directory
-                                 (mpc-file-local-copy (cdr (assq 'file info))))))
+                     (let ((dir (file-name-directory (cdr (assq 'file info)))))
                        ;; (debug)
                        (push `(equal ',dir (file-name-directory (cdr (assq 'file info)))) pred)
                        (if-let ((covers '(".folder.png" "cover.jpg" "folder.jpg"))
-                                (cover (cl-loop for file in (directory-files dir)
+                                (cover (cl-loop for file in (directory-files (mpc-file-local-copy dir))
                                                 if (member (downcase file) covers)
                                                 return (concat dir file)))
                                 (file (with-demoted-errors "MPC: %s"
@@ -1128,23 +1127,24 @@ If PLAYLIST is t or nil or missing, use the main playlist."
     (define-key map "s" 'mpc-toggle-play)
     (define-key map ">" 'mpc-next)
     (define-key map "<" 'mpc-prev)
-    (define-key map "g" nil)
+    (define-key map "g" 'mpc-seek-current)
     map))
 
 (easy-menu-define mpc-mode-menu mpc-mode-map
   "Menu for MPC.el."
   '("MPC.el"
-    ["Play/Pause" mpc-toggle-play]
-    ["Next Track" mpc-next]
-    ["Previous Track" mpc-prev]
+    ["Play/Pause" mpc-toggle-play]      ;FIXME: Add one of ⏯/▶/⏸ in there?
+    ["Next Track" mpc-next]             ;FIXME: Add ⇥ there?
+    ["Previous Track" mpc-prev]         ;FIXME: Add ⇤ there?
+    ["Seek Within Track" mpc-seek-current]
     "--"
-    ["Repeat Playlist" mpc-repeat :style toggle
+    ["Repeat Playlist" mpc-toggle-repeat :style toggle
      :selected (member '(repeat . "1") mpc-status)]
-    ["Shuffle Playlist" mpc-shuffle :style toggle
+    ["Shuffle Playlist" mpc-toggle-shuffle :style toggle
      :selected (member '(random . "1") mpc-status)]
-    ["Repeat Single Track" mpc-single :style toggle
+    ["Repeat Single Track" mpc-toggle-single :style toggle
      :selected (member '(single . "1") mpc-status)]
-    ["Consume Mode" mpc-consume :style toggle
+    ["Consume Mode" mpc-toggle-consume :style toggle
      :selected (member '(consume . "1") mpc-status)]
     "--"
     ["Add new browser" mpc-tagbrowser]
@@ -2362,25 +2362,25 @@ 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 ()
+(defun mpc-toggle-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 ()
+(defun mpc-toggle-repeat ()
   "Toggle repeat mode."
   (interactive)
   (mpc-cmd-repeat
    (if (string= "0" (cdr (assq 'repeat (mpc-cmd-status)))) "1" "0")))
 
-(defun mpc-single ()
+(defun mpc-toggle-single ()
   "Toggle single mode."
   (interactive)
   (mpc-cmd-single
    (if (string= "0" (cdr (assq 'single (mpc-cmd-status)))) "1" "0")))
 
-(defun mpc-shuffle ()
+(defun mpc-toggle-shuffle ()
   "Toggle shuffling of the playlist (random mode)."
   (interactive)
   (mpc-cmd-random
@@ -2403,6 +2403,12 @@ This is used so that they can be compared with `eq', which is needed for
   (interactive)
   (mpc-cmd-pause "0"))
 
+(defun mpc-seek-current (pos)
+  "Seek within current track."
+  (interactive
+   (list (read-string "Position to go ([+-]seconds): ")))
+  (mpc-cmd-seekcur pos))
+
 (defun mpc-toggle-play ()
   "Toggle between play and pause.
 If stopped, start playback."