From 0ff0270717b428de630b5dd6819ea2e3dbab3d95 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 12 Jan 2021 21:16:54 +0000 Subject: espotify: richer marginalia --- eos/jao-minibuffer.el | 4 ++-- media/espotify.org | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/eos/jao-minibuffer.el b/eos/jao-minibuffer.el index b626151..09c94bd 100644 --- a/eos/jao-minibuffer.el +++ b/eos/jao-minibuffer.el @@ -1,6 +1,6 @@ ;;; jao-minibuffer.el --- using the minibuffer to report status -*- lexical-binding: t; -*- -;; Copyright (C) 2020 jao +;; Copyright (C) 2020, 2021 jao ;; Author: jao ;; Keywords: extensions @@ -127,7 +127,7 @@ (setq set-message-function #'jao-minibuffer--set-message) (setq clear-message-function #'jao-minibuffer-refresh) -(setq resize-mini-windows nil) +;; (setq resize-mini-windows nil) (provide 'jao-minibuffer) ;;; jao-minibuffer.el ends here 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