rework emms config
authorJoerg Jaspert <joerg@ganneff.de>
Fri, 12 Jul 2013 12:44:10 +0000 (14:44 +0200)
committerJoerg Jaspert <joerg@ganneff.de>
Fri, 12 Jul 2013 12:44:10 +0000 (14:44 +0200)
.emacs.d/config/emacs.org

index 745cdf4..5802956 100644 (file)
@@ -2849,90 +2849,143 @@ Programming in ruby...
 #+END_SRC
 ** emms
 EMMS is the Emacs Multimedia System.
-https://github.com/Corsair/my-configs/blob/master/.emacs-emms.el
 #+BEGIN_SRC emacs-lisp tangle:yes
-(require 'emms-setup)
-(emms-standard)
+(require 'emms-source-file)
+(require 'emms-source-playlist)
+(require 'emms-info)
+(require 'emms-cache)
+(require 'emms-playlist-mode)
+(require 'emms-playing-time)
 (require 'emms-player-mpd)
-(eval-after-load "emms"
-  '(progn
+(require 'emms-playlist-sort)
+(require 'emms-mark)
+(require 'emms-browser)
+(require 'emms-lyrics)
+(require 'emms-last-played)
+(require 'emms-score)
+
+(setq emms-playlist-default-major-mode 'emms-playlist-mode)
+(add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
+(emms-playing-time 1)
+(emms-lyrics 1)
+(add-hook 'emms-player-started-hook 'emms-last-played-update-current)
+(emms-score 1)
+(when (fboundp 'emms-cache) ; work around compiler warning
+  (emms-cache 1))
+(setq emms-score-default-score 3)
+
+(defun emms-mpd-init ()
+  "Connect Emms to mpd."
+  (interactive)
+  (emms-player-mpd-connect))
 
-     (setq emms-player-mpd-server-name "localhost")
-     (setq emms-player-mpd-server-port "6600")
-     (add-to-list 'emms-info-functions 'emms-info-mpd)
-     (setq emms-volume-change-function 'emms-volume-mpd-change)
-     (add-to-list 'emms-(point)layer-list 'emms-player-mpd)
-     (setq emms-last-played-format-(and )list
-      '(((emms-last-played-seconds-today) . "%a %H:%M")
+;; players
+(require 'emms-player-mpd)
+(setq emms-player-mpd-server-name "localhost")
+(setq emms-player-mpd-server-port "6600")
+(add-to-list 'emms-info-functions 'emms-info-mpd)
+(add-to-list 'emms-player-list 'emms-player-mpd)
+(setq emms-volume-change-function 'emms-volume-mpd-change)
+(setq emms-player-mpd-sync-playlist t)
+
+(setq emms-source-file-default-directory "/var/lib/mpd/music")
+(setq emms-player-mpd-music-directory "/var/lib/mpd/music")
+(setq emms-info-auto-update t)
+(setq emms-lyrics-scroll-p t)
+(setq emms-lyrics-display-on-minibuffer t)
+(setq emms-lyrics-display-on-modeline nil)
+(setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
+
+(setq emms-last-played-format-alist
+      '(((emms-last-played-seconds-today) . "%H:%M")
         (604800                           . "%a %H:%M") ; this week
-        ((emms-last-played-seconds-month) . "%d")
-        ((emms-last-played-seconds-year)  . "%m/%d")
-        (t                                . "%Y/%m/%d")))
-
-     (setq xwl-emms-playlist-last-track nil)
-     (setq xwl-emms-playlist-last-indent "\\")
-
-     (defun xwl-emms-track-description-function (track)
-       "Return a description of the current track."
-       (let* ((name (emms-track-name track))
-              (type (emms-track-type track))
-              (short-name (file-name-nondirectory name))
-              (play-count (or (emms-track-get track 'play-count) 0))
-              (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
-              (empty "..."))
-         (prog1
-             (case (emms-track-type track)
-               ((file url)
-                (let* ((artist (or (emms-track-get track 'info-artist) empty))
-                       (year (emms-track-get track 'info-year))
-                       (playing-time (or (emms-track-get track 'info-playing-time) 0))
-                       (min (/ playing-time 60))
-                       (sec (% playing-time 60))
-                       (album (or (emms-track-get track 'info-album) empty))
-                       (tracknumber (emms-track-get track 'info-tracknumber))
-                       (short-name (file-name-sans-extension
-                                    (file-name-nondirectory name)))
-                       (title (or (emms-track-get track 'info-title) short-name))
-
-                       ;; last track
-                       (ltrack xwl-emms-playlist-last-track)
-                       (lartist (or (and ltrack (emms-track-get ltrack 'info-artist))
-                                    empty))
-                       (lalbum (or (and ltrack (emms-track-get ltrack 'info-album))
-                                   empty))
-
-                       (same-album-p (and (not (string= lalbum empty))
-                                          (string= album lalbum))))
-                  (format "%10s  %3d   %-20s%6s %-55s%-35s%-15s%s"
-                          (emms-last-played-format-date last-played)
-                          play-count
-                          artist
-                          (if (and tracknumber ; tracknumber
-                                     (not (zerop (string-to-number tracknumber))))
-                                (format "%02d." (string-to-number tracknumber))
-                              "")
-                          title
-
-                          ;; album
-                          (cond ((string= album empty) empty)
-                                ;; (same-album-p "  ")
-                                (t (concat "«" album "»")))
-
-                          (or year empty)
-                          (if (or (> min 0)  (> sec 0))
-                              (format "%02d:%02d" min sec)
-                            empty))))
-               ((url)
-                (concat (symbol-name type) ":" name))
-               (t
-                (format "%-3d%s"
-                        play-count
-                        (concat (symbol-name type) ":" name))))
-           (setq xwl-emms-playlist-last-track track))))
-
-     (setq emms-track-description-function
-           'xwl-emms-track-description-function)
-     ))
+        ((emms-last-played-seconds-month) . "%d.%m.%Y")
+        ((emms-last-played-seconds-year)  . "%d.%m.%Y")
+        (t                                . "Never played")))
+
+;; Playlist format
+(defun my-describe (track)
+  (let* ((empty "...")
+         (name (emms-track-name track))
+         (type (emms-track-type track))
+         (short-name (file-name-nondirectory name))
+         (play-count (or (emms-track-get track 'play-count) 0))
+         (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
+         (artist (or (emms-track-get track 'info-artist) empty))
+         (year (emms-track-get track 'info-year))
+         (playing-time (or (emms-track-get track 'info-playing-time) 0))
+         (min (/ playing-time 60))
+         (sec (% playing-time 60))
+         (album (or (emms-track-get track 'info-album) empty))
+         (tracknumber (emms-track-get track 'info-tracknumber))
+         (short-name (file-name-sans-extension
+                      (file-name-nondirectory name)))
+         (title (or (emms-track-get track 'info-title) short-name))
+         (rating (emms-score-get-score name))
+         (rate-char ?☭)
+         )
+    (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
+            (emms-last-played-format-date last-played)
+            artist
+            year
+            album
+            (if (and tracknumber ; tracknumber
+                     (not (zerop (string-to-number tracknumber))))
+                (format "%02d" (string-to-number tracknumber))
+              "")
+            title
+            play-count
+            (make-string rating rate-char)))
+)
+
+(setq emms-track-description-function 'my-describe)
+
+;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
+;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
+(global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
+(global-set-key (kbd "H-<f9> d") 'emms-play-dired)
+(global-set-key (kbd "H-<f9> x") 'emms-start)
+(global-set-key (kbd "H-<f9> v") 'emms-stop)
+(global-set-key (kbd "H-<f9> n") 'emms-next)
+(global-set-key (kbd "H-<f9> p") 'emms-previous)
+(global-set-key (kbd "H-<f9> o") 'emms-show)
+(global-set-key (kbd "H-<f9> h") 'emms-shuffle)
+(global-set-key (kbd "H-<f9> SPC") 'emms-pause)
+(global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
+(global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
+(global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
+
+(global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
+(global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
+(global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
+(global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
+
+(global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
+(global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
+(global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
+(global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
+
+(global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
+(global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
+(global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
+(global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
+
+;; Faces
+(if (window-system)
+    ((lambda ()
+       (set-face-attribute
+        'emms-browser-artist-face nil
+        :family "Arno Pro")
+       )
+))
+
+(setq emms-player-mpd-supported-regexp
+      (or (emms-player-mpd-get-supported-regexp)
+          (concat "\\`http://\\|"
+                  (emms-player-simple-regexp
+                   "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
+(emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
+      
 #+END_SRC
 * Thats it
 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]