From 56fd2cbd65e338352dd672c0eac09e1a0155a3f9 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 3 Jan 2025 13:24:26 -0500 Subject: [PATCH] (mpc-cmd-find): Try and fix bug#41493 * lisp/mpc.el (mpc--proc-alist-to-alists): Don't presume that we have either `directory` or `file` entries, instead allow both at the same time. (mpc-cmd-find) : Don't presume that `directory` entries have no associated data, so throw them away only after having parsed them with `mpc--proc-alist-to-alists`. (cherry picked from commit 3740d9c83825546e0fbde05492777fff221e9fbd) --- lisp/mpc.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lisp/mpc.el b/lisp/mpc.el index 66c804f2af0..4c37da65b10 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -306,13 +306,15 @@ PORT defaults to 6600 and HOST defaults to localhost." (defconst mpc--proc-alist-to-alists-starters '(file directory)) (defun mpc--proc-alist-to-alists (alist) + ;; ALIST is assumed to contain a flattened sequence of sequences, + ;; of the form (file . ..) ..filedata.. (directory . ..) ..dirdata.. + ;; See bug#41493. (cl-assert (or (null alist) (memq (caar alist) mpc--proc-alist-to-alists-starters))) - (let ((starter (caar alist)) - (alists ()) + (let ((alists ()) tmp) (dolist (pair alist) - (when (eq (car pair) starter) + (when (memq (car pair) mpc--proc-alist-to-alists-starters) (if tmp (push (nreverse tmp) alists)) (setq tmp ())) (push pair tmp)) @@ -634,15 +636,15 @@ The songs are returned as alists." (mpc-proc-buf-to-alists (mpc-proc-cmd (list "search" "any" value)))) ((eq tag 'Directory) - (let ((pairs - (mpc-proc-buf-to-alist + (let ((entries + (mpc-proc-buf-to-alists (mpc-proc-cmd (list "listallinfo" value))))) - (mpc--proc-alist-to-alists - ;; Strip away the `directory' entries. - (delq nil (mapcar (lambda (pair) - (if (eq (car pair) 'directory) - nil pair)) - pairs))))) + ;; Strip away the `directory' entries because our callers + ;; currently don't know what to do with them. + (delq nil (mapcar (lambda (entry) + (if (eq (caar entry) 'directory) + nil entry)) + entries)))) ((string-match "|" (symbol-name tag)) (add-to-list 'mpc--find-memoize-union-tags tag) (let ((tag1 (intern (substring (symbol-name tag) -- 2.39.5