Subject: bug#41493: 26.3; Error in MPC directory browser

From: john muhl <[email-masked]>
Date: Tue, 31 Dec 2024 13:26:21 -0600

Stefan Kangas <[email-masked]> writes:

> Matthieu Lemerre <[email-masked]> writes:
>
>> While discovering MPC I customized the MPC host variable, started MPC,
>> clicked on the Menu to "Add a new browser", then selected Directory.
>> If I click on one of my directories (that mostly contain
>> subdirectories), I get the following error:
>>
>> cl--assertion-failed: Assertion failed: (or (null alist) (memq (caar
>> alist) mpc--proc-alist-to-alists-starters))
>
> Copying in the maintainer of mpd.el here.  Any ideas?

The attached patch fixes it for me. The cause seems to be that the
returned alist for a directory browser has entries for (directory
...) and (Last-Modified ...) and the code was only getting rid of
the former only. That leftover (Last-Modified ...) would then trip
up the assert in mpc--proc-alist-to-alists when it checks with
mpc--proc-alist-to-alists-starters.

>From 542e4e8a444d1b197a94666ed1615b1c6ee65d01 Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Tue, 31 Dec 2024 12:52:32 -0600
Subject: [PATCH] Fix directory browsers in 'mpc' (Bug#41493)

* lisp/mpc.el (mpc-cmd-find): Strip "Last-Modified" pairs so that
the returned alist matches 'mpc--proc-alist-to-alists-starters'.
---
 lisp/mpc.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index 4317fece6fc..05ef546f884 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -644,9 +644,10 @@ mpc-cmd-find
                         (mpc-proc-buf-to-alist
                          (mpc-proc-cmd (list "listallinfo" value)))))
                    (mpc--proc-alist-to-alists
-                    ;; Strip away the `directory' entries.
+                    ;; Strip away the `directory' & `Last-Modified' entries.
                     (delq nil (mapcar (lambda (pair)
-                                        (if (eq (car pair) 'directory)
+                                        (if (or (eq (car pair) 'directory)
+                                                (eq (car pair) 'Last-Modified))
                                             nil pair))
                                       pairs)))))
                 ((string-match "|" (symbol-name tag))
-- 
2.47.1