diff options
author | Yoni Rabkin <yoni@rabkins.net> | 2021-04-29 12:53:15 -0400 |
---|---|---|
committer | Yoni Rabkin <yoni@rabkins.net> | 2021-04-29 12:53:15 -0400 |
commit | 3a8ba30d1fb8d94ab3c63aa678a0059cc8b48b2f (patch) | |
tree | be516b15779a7e0e2f1a9892c404bfad3399454d /emms-playing-time.el | |
parent | 02915f7aa24d27d717ff4821a58f791cffcc174c (diff) |
*.el: Minor improvements and simplifications
* emms-playlist-limit.el (emms-playlist-limit--limit-playlist): Simplify.
* emms-playing-time.el (emms-playing-time-display): Simplify.
* emms-player-mpv.el (emms-player-mpv-ipc-proc)
(emms-player-mpv-ipc-connect-command, emms-player-mpv-ipc-id)
(emms-player-mpv-ipc-stop-command)
(emms-player-mpv-event-connect-hook)
(emms-player-mpv-ipc-conn-emacs-26.1-workaround): Fit docstrings with
80 columns.
* emms-player-mpd.el (emms-player-mpd-ensure-process): Simplify `if`
with identical branches.
* emms-browser.el (emms-browser-run-mode-hooks): Simplify and move it
out of `eval-and-compile`.
(emms-browser-sort-cadr, emms-browser-sort-car): Add `debug` spec.
patch by Stefan Monnier
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 () |