diff options
Diffstat (limited to 'emms-playing-time.el')
-rw-r--r-- | emms-playing-time.el | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/emms-playing-time.el b/emms-playing-time.el index 11dc9e3..e99dc64 100644 --- a/emms-playing-time.el +++ b/emms-playing-time.el @@ -165,55 +165,51 @@ could call `emms-playing-time-enable-display' and (defun emms-playing-time-display () "Display playing time on the mode line." (setq emms-playing-time (round (1+ emms-playing-time))) - (setq emms-playing-time-string "") - (when emms-playing-time-display-p - (let* ((min (/ emms-playing-time 60)) - (sec (% emms-playing-time 60)) - (total-playing-time - (or (emms-track-get - (emms-playlist-current-selected-track) - 'info-playing-time) - 0)) - (total-min-only (/ total-playing-time 60)) - (total-sec-only (% total-playing-time 60))) - (cl-case emms-playing-time-style - ((downtime) ; `downtime' style - (setq emms-playing-time-string - (emms-replace-regexp-in-string - " " "0" - (if (or emms-playing-time-display-short-p - ;; unable to get total playing-time - (eq total-playing-time 0)) - (format "%2d:%2d" min sec) - (format "-%2d:%2d" - (/ (- total-playing-time emms-playing-time) 60) - (% (- total-playing-time sec) 60)))))) - ((bar) ; `bar' style - (if (zerop total-playing-time) - (setq emms-playing-time-string "[==>........]") - (let ((progress "[") - ;; percent based on 10 - (percent (/ (* emms-playing-time 10) total-playing-time))) - (dotimes (_i percent) - (setq progress (concat progress "="))) - (setq progress (concat progress ">")) - (dotimes (_i (- 10 percent)) - (setq progress (concat progress " "))) - (setq progress (concat progress "]")) - (setq emms-playing-time-string progress)))) - (t ; `time' style - (setq emms-playing-time-string - (emms-replace-regexp-in-string - " " "0" - (if (or emms-playing-time-display-short-p - ;; unable to get total playing-time - (eq total-playing-time 0)) - (format "%2d:%2d" min sec) - (format "%2d:%2d/%2s:%2s" - min sec total-min-only total-sec-only)))))) - (setq emms-playing-time-string - (format emms-playing-time-display-format - emms-playing-time-string)))) + (setq emms-playing-time-string + (if (null emms-playing-time-display-p) + "" + (let* ((min (/ emms-playing-time 60)) + (sec (% emms-playing-time 60)) + (total-playing-time + (or (emms-track-get + (emms-playlist-current-selected-track) + 'info-playing-time) + 0)) + (total-min-only (/ total-playing-time 60)) + (total-sec-only (% total-playing-time 60)) + (string + (cl-case emms-playing-time-style + ((downtime) ; `downtime' style + (emms-replace-regexp-in-string + " " "0" + (if (or emms-playing-time-display-short-p + ;; unable to get total playing-time + (eq total-playing-time 0)) + (format "%2d:%2d" min sec) + (format "-%2d:%2d" + (/ (- total-playing-time emms-playing-time) 60) + (% (- total-playing-time sec) 60))))) + ((bar) ; `bar' style + (if (zerop total-playing-time) + "[==>........]" + (let (;; percent based on 10 + (percent (/ (* emms-playing-time 10) + total-playing-time))) + (concat "[" + (make-string percent ?=) + ">" + (make-string (- 10 percent) ?\s) + "]")))) + (t ; `time' style + (emms-replace-regexp-in-string + " " "0" + (if (or emms-playing-time-display-short-p + ;; unable to get total playing-time + (eq total-playing-time 0)) + (format "%2d:%2d" min sec) + (format "%2d:%2d/%2s:%2s" + min sec total-min-only total-sec-only))))))) + (format emms-playing-time-display-format string)))) (force-mode-line-update)) (defun emms-playing-time-mode-line () |