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

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

[nongnu] elpa/mpv fb775e339b 08/12: Use format-spec for mpv-entry-format


From: ELPA Syncer
Subject: [nongnu] elpa/mpv fb775e339b 08/12: Use format-spec for mpv-entry-format
Date: Mon, 1 Aug 2022 09:58:52 -0400 (EDT)

branch: elpa/mpv
commit fb775e339bed5db5ca4f1d837c5c0f7082a37951
Author: Johann Klähn <johann@jklaehn.de>
Commit: Johann Klähn <johann@jklaehn.de>

    Use format-spec for mpv-entry-format
---
 mpv.el | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/mpv.el b/mpv.el
index ae6e8a20da..8a7d784996 100644
--- a/mpv.el
+++ b/mpv.el
@@ -69,8 +69,13 @@
   :type 'number
   :group 'mpv)
 
-(defcustom mpv-entry-format "%s [%s]"
-  "The format of the entries for mpv listing operations."
+(defcustom mpv-entry-format "%t [%o]"
+  "The format of the entries for mpv listing operations.
+
+The following %-escapes will be expanded using `format-spec':
+
+%t      The entry's title.
+%o      The entry's time offset in `[HH:]MM:SS' format."
   :type 'string
   :group 'mpv)
 
@@ -389,14 +394,13 @@ in the current mpv playback."
 Additionally, it sets an indicator for the CURRENT item and/or marks if the 
item
  is currently set to LOOP-P."
   (concat
-   (if time
-       (format mpv-entry-format
-               title
-               (pcase time
-                 ((and n (pred numberp) (guard (< 3600 n)))
-                  (format-time-string "%T" n t))
-                 ((and n (pred numberp))
-                  (format-time-string "%M:%S" n))))
+   (if (numberp time)
+       (format-spec
+        mpv-entry-format
+        `((?t . ,title)
+          (?o . ,(format-time-string
+                  (if (< 3600 time) "%T" "%M:%S")
+                  time t))))
      title)
    (and current mpv-current-indicator)
    (and loop-p mpv-loop-indicator)))



reply via email to

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