Cleanup resources when empc has been disconnected by the server

This commit is contained in:
Renaud Casenave-Péré 2012-08-03 18:42:18 +09:00
parent c4f18da3ba
commit b96930ddeb

11
empc.el
View file

@ -294,7 +294,8 @@ For status:
(status (process-status proc)))
(cond ((eq status 'closed)
(when empc-verbose
(message "empc: connection closed"))))))
(message "empc: connection closed"))
(empc-cleanup)))))
(defun empc-process-filter (object string)
"Append STRING to the process buffer then process the data."
@ -742,10 +743,14 @@ Send the password or retrieve available commands."
"Close connection between empc and mpd."
(interactive)
(let* ((process (empc-process empc-object)))
(when (and process
(if (and process
(processp process)
(eq (process-status process) 'open))
(empc-send-close)))
(empc-send-close)
(empc-cleanup))))
(defun empc-cleanup ()
"Cleanup empc resources after disconnection."
(when empc-object
(empc-close empc-object))
(empc-mode-line nil)