If there is no alive process, don't try to send commands but store then into the queue

This commit is contained in:
Renaud Casenave-Péré 2011-08-27 22:07:59 +09:00
parent cd4eabe65f
commit 18d96b8a8f

13
empc.el
View file

@ -104,12 +104,13 @@ playlist is a vector of song ids, keeping the order of the songs
(defun empc-queue-push (object command closure fn) (defun empc-queue-push (object command closure fn)
"Enqueue '(COMMAND . (CLOSURE . FN)) to the queue of OBJECT. "Enqueue '(COMMAND . (CLOSURE . FN)) to the queue of OBJECT.
Leave the idle state beforehand if necessary." Leave the idle state beforehand if necessary."
(if (empc-queue object) (when (empc-process object)
(when (string= (empc-queue-head-command object) "idle\n") (if (empc-queue object)
(setcar (caaar object) "noidle\n") (when (string= (empc-queue-head-command object) "idle\n")
(process-send-string (empc-process object) "noidle\n")) (setcar (caaar object) "noidle\n")
(when command (process-send-string (empc-process object) "noidle\n"))
(process-send-string (empc-process object) command))) (when command
(process-send-string (empc-process object) command))))
(setcar (car object) (setcar (car object)
(nconc (empc-queue object) (nconc (empc-queue object)
(list (cons command (cons closure fn)))))) (list (cons command (cons closure fn))))))