emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/listen a7da346ac1 10/15: Add: (listen-lighter-format-ra


From: ELPA Syncer
Subject: [elpa] externals/listen a7da346ac1 10/15: Add: (listen-lighter-format-rating)
Date: Tue, 5 Mar 2024 21:58:14 -0500 (EST)

branch: externals/listen
commit a7da346ac1d8009bcd62bfe25256c839c18e1911
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: (listen-lighter-format-rating)
---
 listen.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/listen.el b/listen.el
index c40c2c70c2..c2ccfe774e 100755
--- a/listen.el
+++ b/listen.el
@@ -96,6 +96,7 @@ For the currently playing track."
 Each is called without arguments and should return a string
 without extra whitespace."
   :type '(repeat (choice (const :tag "Remaining queue time" 
listen-queue-format-remaining)
+                         (const :tag "Track rating" 
listen-lighter-format-rating)
                          function)))
 
 (defcustom listen-track-end-functions '(listen-play-next)
@@ -250,6 +251,15 @@ Interactively, jump to current queue's current track."
                      " ")
              '("■ ")))))
 
+(defun listen-lighter-format-rating ()
+  "Return the rating of the current track for display in the lighter."
+  (when-let ((player (listen--player))
+             (queue (map-elt (listen-player-etc player) :queue))
+             (track (listen-queue-current queue))
+             (rating (or (listen-track-rating track)
+                         (map-elt (listen-track-etc track) "fmps_rating"))))
+    (format "[%s]" (* 5 (string-to-number rating)))))
+
 (declare-function listen-queue-play "listen-queue")
 (declare-function listen-queue-next-track "listen-queue")
 (defun listen-mode--update (&rest _ignore)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]