[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ampc 18dc9a9870 041/111: Handle listallinfo chunks righ
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ampc 18dc9a9870 041/111: Handle listallinfo chunks right after receiving them. |
Date: |
Tue, 20 Feb 2024 18:16:39 -0500 (EST) |
branch: externals/ampc
commit 18dc9a98700467066d0ac392f55dab2da8865db3
Author: Christopher Schmidt <christopher@ch.ristopher.com>
Commit: Christopher Schmidt <christopher@ch.ristopher.com>
Handle listallinfo chunks right after receiving them.
---
ampc.el | 77 ++++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 48 insertions(+), 29 deletions(-)
diff --git a/ampc.el b/ampc.el
index 16c03fa642..02b3334d42 100644
--- a/ampc.el
+++ b/ampc.el
@@ -834,6 +834,8 @@ all the time!"
((tag song)
(if (assoc (ampc-tags) ampc-internal-db)
(ampc-fill-tag-song)
+ (push `(,(ampc-tags) . ,(ampc-create-tree))
+ ampc-internal-db)
(ampc-send-command 'listallinfo)))
(status
(ampc-send-command 'status)
@@ -1168,13 +1170,23 @@ all the time!"
"ampc supports MPD (protocol version) 0.15.0 "
"and later"))))
-(defun ampc-fill-internal-db ()
- (push `(,(ampc-tags) . ,(ampc-create-tree)) ampc-internal-db)
- (loop while (search-forward-regexp "^file: " nil t)
+(defun ampc-fill-internal-db (running)
+ (loop for origin = (and (search-forward-regexp "^file: " nil t)
+ (line-beginning-position))
+ then next
+ while origin
+ for next = (progn
+ (forward-char)
+ (and (search-forward-regexp "^file: " nil t)
+ (move-beginning-of-line nil)))
+ while next
do (save-restriction
- (ampc-narrow-entry)
- (ampc-fill-internal-db-entry)))
- (ampc-fill-tag-song))
+ (narrow-to-region origin next)
+ (ampc-fill-internal-db-entry))
+ (goto-char origin)
+ (when running
+ (delete-region origin next)
+ (setf next origin))))
(defun ampc-tags ()
(loop for w in (ampc-windows)
@@ -1240,8 +1252,13 @@ all the time!"
(message "Database update started"))
(defun ampc-handle-command (status)
- (if (eq status 'error)
- (pop ampc-outstanding-commands)
+ (cond
+ ((eq status 'error)
+ (pop ampc-outstanding-commands))
+ ((eq status 'running)
+ (case (caar ampc-outstanding-commands)
+ (listallinfo (ampc-fill-internal-db t))))
+ (t
(case (car (pop ampc-outstanding-commands))
(idle
(ampc-handle-idle))
@@ -1260,12 +1277,11 @@ all the time!"
(playlistinfo
(ampc-fill-current-playlist))
(listallinfo
- (ampc-fill-internal-db))
+ (ampc-fill-internal-db nil))
(outputs
- (ampc-fill-outputs))))
- (unless ampc-outstanding-commands
- (ampc-update))
- (ampc-send-next-command))
+ (ampc-fill-outputs)))
+ (unless ampc-outstanding-commands
+ (ampc-update)))))
(defun ampc-filter (_process string)
(assert (buffer-live-p (process-buffer ampc-connection)))
@@ -1279,22 +1295,25 @@ all the time!"
(save-excursion
(goto-char (point-min))
(let ((success))
- (when (or (and (search-forward-regexp
- "^ACK \\[\\(.*\\)\\] {.*} \\(.*\\)\n\\'"
- nil
- t)
- (message "ampc command error: %s (%s)"
- (match-string 2)
- (match-string 1))
- t)
- (and (search-forward-regexp "^OK\\(.*\\)\n\\'" nil t)
- (setf success t)))
- (let ((match-end (match-end 0)))
- (save-restriction
- (narrow-to-region (point-min) match-end)
- (goto-char (point-min))
- (ampc-handle-command (if success (match-string 1) 'error)))
- (delete-region (point-min) match-end)))))))
+ (if (or (and (search-forward-regexp
+ "^ACK \\[\\(.*\\)\\] {.*} \\(.*\\)\n\\'"
+ nil
+ t)
+ (message "ampc command error: %s (%s)"
+ (match-string 2)
+ (match-string 1))
+ t)
+ (and (search-forward-regexp "^OK\\(.*\\)\n\\'" nil t)
+ (setf success t)))
+ (progn
+ (let ((match-end (match-end 0)))
+ (save-restriction
+ (narrow-to-region (point-min) match-end)
+ (goto-char (point-min))
+ (ampc-handle-command (if success (match-string 1) 'error)))
+ (delete-region (point-min) match-end))
+ (ampc-send-next-command))
+ (ampc-handle-command 'running))))))
;;; **** window management
(defun ampc-windows (&optional unordered)
- [elpa] externals/ampc ee5f78f2ea 019/111: Add new views with a different order of tag browsers., (continued)
- [elpa] externals/ampc ee5f78f2ea 019/111: Add new views with a different order of tag browsers., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 7289f29365 020/111: Add note on how to remap keys in ampc-mode-map., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 76b1125941 025/111: Add ampc-suspend., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 1d2d403a59 026/111: Remove superfluous whitespace., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc cc7f4c8432 031/111: Alias unspecified tags in ampc-status., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 6ea9805c14 034/111: Clarify version error message., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 8b11bf109c 107/111: ; Fix typos, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc ba9840c63f 110/111: ; Depend on Emacs 24.3, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc ed0caf2d07 035/111: Correctly quote arguments before sending them to MPD., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 69bef3a98d 040/111: Fix code alignment., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 18dc9a9870 041/111: Handle listallinfo chunks right after receiving them.,
Stefan Monnier <=
- [elpa] externals/ampc 473ad7dbc3 042/111: Add emacswiki-generator.el., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc d8ba1ed217 045/111: * ampc.el (ampc): Fix typo., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 204540b0de 047/111: * ampc.el (ampc-fill-internal-db): Fix empty region bug., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 5b560e377d 050/111: * ampc.el (ampc-fill-internal-db-entry): Use a better format for storing data., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 383074a3b1 053/111: * ampc.el: Name views., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc b12dedc83d 062/111: * ampc.el: Bump version to 0.1.3., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 6a8bf556e6 066/111: * ampc.el (ampc): Warn if ampc is not byte compiled., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 7600043106 067/111: * ampc.el (ampc-narrow-entry): Return position of next entry., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 376a9f6ece 070/111: * ampc.el (ampc-on-p): Make this function a command., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 5bc124583a 071/111: * ampc.el (ampc-suspended-p): New command., Stefan Monnier, 2024/02/20