(global-set-key [?\C-c ?m ?d] 'magit-dispatch-popup)
(global-set-key [?\C-c ?m ?w] 'magit-wip-log)
(global-set-key [?\C-c ?m ?r] 'magit-list-repositories)
+ (global-set-key [?\C-c ?p ?p] 'mdw-mpc-play-or-pause)
+ (global-set-key [?\C-c ?p ?s] 'mpc-stop)
+ (global-set-key [?\C-c ?p ?<] 'mpc-prev)
+ (global-set-key [?\C-c ?p ?>] 'mpc-next)
+ (global-set-key [?\C-c ?p ??] 'mdw-mpc-now-playing)
(global-set-key [?\C-c ?k] 'compile)
(global-set-key [?\C-x ?3] 'mdw-split-window-horizontally)
(global-set-key [?\M-#] 'calc-dispatch)
(propertize (number-to-string n) 'face
(if (> n 0) 'bold 'shadow))))))
+;;;--------------------------------------------------------------------------
+;;; MPC configuration.
+
+(defun mdw-mpc-play-or-pause ()
+ (interactive)
+ (require 'mpc)
+ (if (member (cdr (assq 'state (mpc-cmd-status))) '("play"))
+ (mpc-pause)
+ (mpc-play)))
+
+(setq mpc-browser-tags '(Artist|Composer|Performer Album|Playlist))
+
+(defun mdw-mpc-now-playing ()
+ (interactive)
+ (require 'mpc)
+ (save-excursion
+ (set-buffer (mpc-proc-cmd (mpc-proc-cmd-list '("status" "currentsong"))))
+ (mpc--status-callback))
+ (let ((state (cdr (assq 'state mpc-status))))
+ (cond ((member state '("stop"))
+ (message "mpd stopped."))
+ ((member state '("play" "pause"))
+ (let* ((artist (cdr (assq 'Artist mpc-status)))
+ (album (cdr (assq 'Album mpc-status)))
+ (title (cdr (assq 'Title mpc-status)))
+ (file (cdr (assq 'file mpc-status)))
+ (duration-string (cdr (assq 'Time mpc-status)))
+ (time-string (cdr (assq 'time mpc-status)))
+ (time (and time-string
+ (parse-integer
+ (if (string-match ":" time-string)
+ (substring time-string
+ 0 (match-beginning 0))
+ (time-string)))))
+ (duration (and duration-string
+ (parse-integer duration-string)))
+ (pos (and time duration
+ (format " [%d:%02d/%d:%02d]"
+ (/ time 60) (mod time 60)
+ (/ duration 60) (mod duration 60))))
+ (fmt (cond ((and artist title)
+ (format "`%s' by %s%s" title artist
+ (if album (format ", from `%s'" album)
+ "")))
+ (file
+ (format "`%s' (no tags)" file))
+ (t
+ "(no idea what's playing!)"))))
+ (if (string= state "play")
+ (message "mpd playing %s%s" fmt (or pos ""))
+ (message "mpd paused in %s%s" fmt (or pos "")))))
+ (t
+ (message "mpd in unknown state `%s'" state)))))
+
+(autoload 'mpc-pause "mpc")
+(autoload 'mpc-next "mpc")
+(autoload 'mpc-prev "mpc")
+
;;;--------------------------------------------------------------------------
;;; Inferior Emacs Lisp.