From 0ff0270717b428de630b5dd6819ea2e3dbab3d95 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 12 Jan 2021 21:16:54 +0000 Subject: espotify: richer marginalia --- media/espotify.org | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'media') diff --git a/media/espotify.org b/media/espotify.org index 7b22cc0..6f001fd 100644 --- a/media/espotify.org +++ b/media/espotify.org @@ -311,7 +311,11 @@ Let's start with an umbrella customization group: #+begin_src emacs-lisp (defun espotify--format-item (x) - (propertize (format "%s" (alist-get 'name x)) 'espotify-item x)) + (propertize (format "%s%s" + (alist-get 'name x) + (if-let ((a (alist-get 'album x))) + (format " (%s)" (alist-get 'name a)))) + 'espotify-item x)) (defun espotify--item (cand) (get-text-property 0 'espotify-item cand)) @@ -379,11 +383,17 @@ Let's start with an umbrella customization group: (when-let (x (espotify--item cand)) (marginalia--fields ((alist-get 'type x "") :face 'marginalia-mode :width 10) + ((if-let (d (alist-get 'duration_ms x)) + (let ((secs (/ d 1000))) + (format "%02d:%02d" (/ secs 60) (mod secs 60))) + "")) ((or (alist-get 'name (car (alist-get 'artists x))) "") :face 'marginalia-file-name :width 50) ((if-let (d (alist-get 'total_tracks x)) (format "%s tracks" d) "") :face 'marginalia-size :width 12) - ((if-let (d (alist-get 'release_date x)) (format "%s" d) "") + ((if-let (d (alist-get 'release_date (alist-get 'album x x))) + (format "%s" d) + "") :face 'marginalia-modified :width 10)))) (add-to-list 'marginalia-annotators-heavy -- cgit v1.2.3