diff --git a/empc.el b/empc.el index b09050f..b90d84c 100644 --- a/empc.el +++ b/empc.el @@ -200,35 +200,43 @@ For status: (defun empc-song-to-string (song) "Return a string as per `empc-playlist-song-format' variable using SONG's attributes." - (let* ((time (empc-time-to-string (plist-get song :time))) - (file (plist-get song :file)) - (artist (plist-get song :artist)) - (title (plist-get song :title)) - (album (plist-get song :album)) - (date (number-to-string (plist-get song :date))) - (track (plist-get song :track)) - (genre (plist-get song :genre)) - (pos (number-to-string (plist-get song :pos))) - (string-format `(concat ,@empc-song-format))) - (eval string-format))) + (if song + (let* ((time (empc-time-to-string (plist-get song :time))) + (file (plist-get song :file)) + (artist (plist-get song :artist)) + (title (plist-get song :title)) + (album (plist-get song :album)) + (date (when (plist-member song :date) (number-to-string (plist-get song :date)))) + (track (plist-get song :track)) + (genre (plist-get song :genre)) + (pos (number-to-string (plist-get song :pos))) + (string-format `(concat ,@empc-song-format))) + (eval string-format)) + "")) (defun empc-mode-line-to-string () "Return a string as per `empc-mode-line-format'." - (let* ((song (empc-current-song empc-object)) - (status (empc-status empc-object)) - (time (empc-time-to-string (plist-get song :time))) - (file (plist-get song :file)) - (artist (plist-get song :artist)) - (title (plist-get song :title)) - (album (plist-get song :album)) - (date (number-to-string (plist-get song :date))) - (track (plist-get song :track)) - (genre (plist-get song :genre)) - (pos (number-to-string (1+ (plist-get song :pos)))) - (playlistlength (number-to-string (plist-get status :playlistlength))) - (state (symbol-name (plist-get status :state))) - (string-format `(concat ,@empc-mode-line-format))) - (eval string-format))) + (if song + (let* ((song (empc-current-song empc-object)) + (status (empc-status empc-object)) + (time (empc-time-to-string (plist-get song :time))) + (file (plist-get song :file)) + (artist (plist-get song :artist)) + (title (plist-get song :title)) + (album (plist-get song :album)) + (date (when (plist-member song :date) (number-to-string (plist-get song :date)))) + (track (plist-get song :track)) + (genre (plist-get song :genre)) + (pos (number-to-string (1+ (plist-get song :pos)))) + (playlistlength (number-to-string (plist-get status :playlistlength))) + (state (symbol-name (plist-get status :state))) + (string-format `(concat ,@empc-mode-line-format))) + (eval string-format)) + (let* ((status (empc-status empc-object)) + (state (symbol-name (plist-get status :state))) + (playlistlength (number-to-string (plist-get status :playlistlength))) + (string-format `(concat ,@empc-mode-line-format))) + (eval string-format)))) (defvar empc-last-crossfade nil) (defvar empc-mode-line-string "")