Rewrite `empc-update-status' to report (correctly) only the relevant messages
This commit is contained in:
parent
b8f31a51b9
commit
4e414e55f9
1 changed files with 13 additions and 11 deletions
24
empc.el
24
empc.el
|
|
@ -127,17 +127,19 @@ form '('error (error-code . error-message))."
|
|||
(defun empc-update-status (new-status)
|
||||
"Determine the differences between the stored status and the new one
|
||||
then update what needs to be."
|
||||
(cond
|
||||
((not (eq (plist-get empc-current-status :state) (plist-get new-status :state)))
|
||||
(if (eq (plist-get new-status :state) 'play)
|
||||
(progn
|
||||
(unless (eq (plist-get empc-current-status :song) (plist-get new-status :song))
|
||||
(setq empc-current-song (aref empc-current-playlist (plist-get new-status :song))))
|
||||
(empc-echo-current-song))
|
||||
(empc-echo-notify (if (eq (plist-get new-status :state) 'pause) "Pause" "Stop"))))
|
||||
((not (eq (plist-get empc-current-status :playlist) (plist-get new-status :playlist)))
|
||||
(empc-echo-notify "Playlist changed")))
|
||||
(setq empc-current-status new-status))
|
||||
(let ((new-song empc-current-song))
|
||||
(unless (and (eq (plist-get empc-current-status :song) (plist-get new-status :song))
|
||||
(eq (plist-get empc-current-song :pos) (plist-get new-status :song)))
|
||||
(setq new-song (aref empc-current-playlist (plist-get new-status :song))))
|
||||
(unless (eq (plist-get empc-current-status :state) (plist-get new-status :state))
|
||||
(if (or (eq (plist-get new-status :state) 'play)
|
||||
(not (eq (plist-get new-song :pos) (plist-get empc-current-song :pos))))
|
||||
(empc-echo-current-song)
|
||||
(empc-echo-notify (if (eq (plist-get new-status :state) 'pause) "Pause" "Stop"))))
|
||||
(unless (eq (plist-get empc-current-status :playlist) (plist-get new-status :playlist))
|
||||
(empc-echo-notify "Playlist changed"))
|
||||
(setq empc-current-song new-song)
|
||||
(setq empc-current-status new-status)))
|
||||
|
||||
(defun empc-response-get-status (data)
|
||||
"Arrange DATA into a plist and store it into EMPC-CURRENT-STATUS."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue