Show emms playing title in the mode-line

This commit is contained in:
Tom Willemse 2013-05-01 12:26:06 +02:00
parent e75266aad4
commit a5cea3ece7
2 changed files with 44 additions and 10 deletions

View file

@ -1296,6 +1296,36 @@
(add-hook 'smartparens-mode-on-hook 'oni:smartparens-set-keys) (add-hook 'smartparens-mode-on-hook 'oni:smartparens-set-keys)
#+END_SRC #+END_SRC
* Initialize EMMS :emms:
Initialize a minimal EMMS setup. Load the default players so we can
use mplayer or any of the generic mp3 and ogg players.
Load the MPD player so we can connect to MPD and use that if
possible, set the music directory to MPD's music directory so it
knows how to translate filenames to something MPD understands.
Load the =emms-mode-line= module so we can display some information in
the mode-line about which song is playing and set my preferred
function for extracting this information. The =emms-info-mpd= function
doesn't seem to return anything, so I've had to improvise to turn
absolute file names into something nicer.
#+BEGIN_SRC emacs-lisp
(eval-after-load "emms"
`(progn
(emms-minimalistic)
(emms-default-players)
(require 'emms-player-mpd)
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-music-directory "/mnt/music/mp3")
(require 'emms-mode-line)
(setq emms-mode-line-mode-line-function 'oni:mode-line-current-song)
(emms-mode-line 1)))
#+END_SRC
* All the rest * All the rest
This still needs to be sorted out and documented, haven't had time This still needs to be sorted out and documented, haven't had time
@ -1517,16 +1547,6 @@
(setq eap-music-library "/mnt/music") (setq eap-music-library "/mnt/music")
(setq eap-playlist-library "~/music/playlists") (setq eap-playlist-library "~/music/playlists")
;;;; EMMS
(eval-after-load "emms"
`(progn
(emms-minimalistic)
(emms-default-players)
(require 'emms-player-mpd)
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-music-directory "/mnt/music/mp3")))
;;;; Auto-complete ;;;; Auto-complete
(setq-default ac-sources '(ac-source-imenu (setq-default ac-sources '(ac-source-imenu

View file

@ -260,6 +260,20 @@ code. Found at http://xahlee.org/emacs/elisp_parse_time.html"
(match-string 2 date-string) (match-string 2 date-string)
(match-string 1 date-string))) (match-string 1 date-string)))
(defun oni:mode-line-current-song ()
"Extract current song information from a path.
EMMS only shows me the absolute path of a song, this function
extracts the parts I want to know about."
(let* ((song (emms-track-name (emms-playlist-current-selected-track)))
(matchp (string-match "\\([^/]+\\)/\\([0-9]\\{4\\}\\) - \\(.+\\)/\\([0-9]\\{2,3\\}\\) - \\(.+\\)\\..\\{3,4\\}$" song))
(band (substring song (match-beginning 1) (match-end 1)))
(year (substring song (match-beginning 2) (match-end 2)))
(album (substring song (match-beginning 3) (match-end 3)))
(track (substring song (match-beginning 4) (match-end 4)))
(title (substring song (match-beginning 5) (match-end 5))))
(format "[%s - %s]" band title)))
(defun oni:move-beginning-of-dwim () (defun oni:move-beginning-of-dwim ()
"Move to beginning of line either after indentation or before." "Move to beginning of line either after indentation or before."
(interactive) (interactive)