summaryrefslogtreecommitdiffstats
path: root/emacs/site-lisp/oni.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-05-01 12:26:06 +0200
committerGravatar Tom Willemse2013-05-01 12:26:06 +0200
commita5cea3ece7c46fdb0eb88cb1eb6013658fc9ff3d (patch)
treef91291b3b9b9c5481a16a575db7deb48045937ff /emacs/site-lisp/oni.el
parente75266aad4b62d357be8e80c47d2623e392663fe (diff)
downloaddotfiles-a5cea3ece7c46fdb0eb88cb1eb6013658fc9ff3d.tar.gz
dotfiles-a5cea3ece7c46fdb0eb88cb1eb6013658fc9ff3d.zip
Show emms playing title in the mode-line
Diffstat (limited to 'emacs/site-lisp/oni.el')
-rw-r--r--emacs/site-lisp/oni.el14
1 files changed, 14 insertions, 0 deletions
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)