Tentative to fix string formats if some informations are missing.

This commit is contained in:
Renaud Casenave-Péré 2011-08-27 17:40:47 +09:00
parent dd6431a10f
commit 0cd8704346

60
empc.el
View file

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