From 667b7b842d60ac2aa5f371883c4fd495ea6ac99f Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 1 Nov 2020 02:13:43 +0000 Subject: tweaks to emms track info --- emms/jao-emms-info-track.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/emms/jao-emms-info-track.el b/emms/jao-emms-info-track.el index f1d922d..ea3513e 100644 --- a/emms/jao-emms-info-track.el +++ b/emms/jao-emms-info-track.el @@ -71,7 +71,17 @@ (string-to-number (match-string 1 x))))) (defun jao-emms--fmt-time (x suffix) - (if x (format "%02d:%02d%s" (/ x 60) (mod x 60) suffix) "")) + (if x (format "%02d:%02d%s" (/ x 60) (mod x 60) (or suffix "")) "")) + +(defun jao-emms--fmt-song-times (track lapsed pre post) + (if lapsed + (let ((time (when track (emms-track-get track 'info-playing-time)))) + (format "%s%s%s%s" + (or pre "") + (jao-emms--fmt-time lapsed (when time "/")) + (jao-emms--fmt-time time "") + (or post ""))) + "")) (defun jao-emms-info-track-file (track &optional lapsed plen titlesep) "Return a description of the current track." @@ -94,11 +104,7 @@ (jao--put-face title 'jao-emms-font-lock-title) (or titlesep " ") - (if lapsed - (format "[%s%s] " - (jao-emms--fmt-time lapsed "/") - (jao-emms--fmt-time time "")) - "") + (jao-emms--fmt-song-times track lapsed "[" "] ") (jao--put-face artist 'jao-emms-font-lock-artist) (jao--put-face (if composer (format " [%s]" composer) "") 'jao-emms-font-lock-artist) @@ -160,12 +166,16 @@ (info-note . "c"))))) (defvar jao-emms-echo-string "") -(defun jao-emms-update-echo-string (&optional track) - (if (and emms-player-playing-p (not emms-player-paused-p)) +(defun jao-emms-update-echo-string (&optional existing-track) + (if emms-player-playing-p (jao-emms--with-mpd-track - (lambda (track _ play-len) + (lambda (track lapsed play-len) (setq jao-emms-echo-string - (jao-emms-info-track-description track nil play-len)) + (if emms-player-paused-p + (if existing-track + (jao-emms--fmt-song-times existing-track lapsed "(" ")") + "ยง") + (jao-emms-info-track-description track nil play-len))) (jao-minibuffer-refresh))) (setq jao-emms-echo-string "") (jao-minibuffer-refresh))) -- cgit v1.2.3