]> git.eshelyaron.com Git - emacs.git/commitdiff
(mpc-cmd-find): Try and fix bug#41493
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 3 Jan 2025 18:24:26 +0000 (13:24 -0500)
committerEshel Yaron <me@eshelyaron.com>
Sat, 4 Jan 2025 20:56:30 +0000 (21:56 +0100)
* 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) <Directory>: 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

index 66c804f2af03705a35bc049e1c438bf826e7618b..4c37da65b107be29e70a96e6671e8a52cb5813f6 100644 (file)
@@ -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)