From a5cea3ece7c46fdb0eb88cb1eb6013658fc9ff3d Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 1 May 2013 12:26:06 +0200 Subject: Show emms playing title in the mode-line --- emacs/init.org | 40 ++++++++++++++++++++++++++++++---------- emacs/site-lisp/oni.el | 14 ++++++++++++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/emacs/init.org b/emacs/init.org index 619a17b..188e384 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -1296,6 +1296,36 @@ (add-hook 'smartparens-mode-on-hook 'oni:smartparens-set-keys) #+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 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-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 (setq-default ac-sources '(ac-source-imenu diff --git a/emacs/site-lisp/oni.el b/emacs/site-lisp/oni.el index 544d215..2436e53 100644 --- a/emacs/site-lisp/oni.el +++ b/emacs/site-lisp/oni.el @@ -260,6 +260,20 @@ code. Found at http://xahlee.org/emacs/elisp_parse_time.html" (match-string 2 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 () "Move to beginning of line either after indentation or before." (interactive) -- cgit v1.2.3-54-g00ecf