branch: externals/ampc
commit edda56364ffb77f712166972b759441f954b6a3c
Author: Christopher Schmidt <christop...@ch.ristopher.com>
Commit: Christopher Schmidt <christop...@ch.ristopher.com>

    * ampc.el (ampc-synchronous-commands): New constant.
    (ampc-send-next-command): Use synchronous I/O for all commands in
    ampc-synchronous-commands.
---
 ampc.el | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/ampc.el b/ampc.el
index df7d31defb..f81551a21a 100644
--- a/ampc.el
+++ b/ampc.el
@@ -375,6 +375,8 @@ all the time!"
 (defvar ampc-internal-db nil)
 (defvar ampc-status nil)
 
+(defconst ampc-synchronous-commands '(listallinfo current-playlist))
+
 ;;; *** mode maps
 (defvar ampc-mode-map
   (let ((map (make-sparse-keymap)))
@@ -984,13 +986,18 @@ all the time!"
 (defun ampc-send-next-command ()
   (unless ampc-outstanding-commands
     (ampc-send-command 'idle))
-  (ampc-send-command-impl
-   (concat (replace-regexp-in-string
-            "^.*-" "" (symbol-name (caar ampc-outstanding-commands)))
-           (loop for a in (cdar ampc-outstanding-commands)
-                 concat " "
-                 concat (cond ((integerp a) (number-to-string a))
-                              (t a))))))
+  (let ((command (replace-regexp-in-string
+                  "^.*-" "" (symbol-name (caar ampc-outstanding-commands)))))
+    (ampc-send-command-impl
+     (concat command
+             (loop for a in (cdar ampc-outstanding-commands)
+                   concat " "
+                   concat (cond ((integerp a) (number-to-string a))
+                                (t a)))))
+    (when (member (intern command) ampc-synchronous-commands)
+      (loop with head = ampc-outstanding-commands
+            while (eq head ampc-outstanding-commands)
+            do (accept-process-output nil 0 100)))))
 
 (defun ampc-tree< (a b)
   (string< (car a) (car b)))

Reply via email to