[Top][All Lists]

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

[PATCH] emms-browser.el: Fix bug in emms-browser-format-spec

From: Scarlett McAllister
Subject: [PATCH] emms-browser.el: Fix bug in emms-browser-format-spec
Date: Sun, 26 Mar 2023 17:36:11 -0300

Sometimes, emms-browser-format-spec will throw an "Invalid format character" error, even when supplied a valid character format. This happens because the propertized string returned by emms-browser-format-line may contain an item with a car but no cdr (e.g.: ("y") instead of ("y" . 2023)). This patch fixes that by throwing the error only if the propertized string doesn't contain the key. Then, in circumstances where it does contain the key but the value is nil, it will supply an empty string to the text formatting procedure.

diff --git a/emms-browser.el b/emms-browser.el
index 6a75cdb..1769881 100644
--- a/emms-browser.el
+++ b/emms-browser.el
@@ -1847,9 +1847,12 @@ the text that it generates."
        ((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]+\\)")
         (let* ((num (match-string 1))
                (spec (match-string 2))
-               (val (cdr (assoc spec specification))))
-          (unless val
+               (val-alist (assoc spec specification))
+               (val (cdr val-alist)))
+          (unless val-alist
             (error "Invalid format character: %s" spec))
+          ;; Value for a valid spec may not exist. Not an error, just nothing to show.
+          (unless val (setq val ""))
           ;; Pad result to desired length.
           (let ((text (format (concat "%" num "s") val)))
             ;; Insert first, to preserve text properties.

reply via email to

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