From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#41493: 26.3; Error in MPC directory browser Date: Wed, 01 Jan 2025 13:22:01 -0500 Message-ID: References: <87pnaue55o.fsf@x1.intra> <87ed1npsbm.fsf@pub.pink> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5682"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 41493@debbugs.gnu.org, Matthieu Lemerre , Stefan Kangas To: john muhl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 01 19:23:21 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tT3NH-0001KX-En for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jan 2025 19:23:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tT3N1-0004pa-ST; Wed, 01 Jan 2025 13:23:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tT3N0-0004p9-8k for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2025 13:23:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tT3N0-0004Sz-0N for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2025 13:23:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=VI8i/0mTqa+XdI/RI6edexvcEzHFC+3lMHxq2jEsMyM=; b=qW8dxnS2iuCNfxGezcjspg4ZLvMG9tut72XlylfVUpxMmtLIkrBUrQsNkYZnDyLvGgbNEOoNPfwryBctpn4x32qMtB2tyupRJmMnb6X56thjKhJ4sxzfdWALerJ8ZmfCU25m+hcILSKdCbxNn1KU70a/sENQPMrj926UM0KWQS7LJnChsxcFNwy0UqZa7Rd6B9Yh3tUP+/ncLkneftYvNFAzyo25KCMUHpg9/6qPNKpcEblOUzeQ+okrb8wRmnDHckOezr4xibYxIu25ehKr8HLEmg7cQo+5RvEI89TgefHQCMsy9J5pUbhpvJixcqfoT5Dfh18xlOTpzOhsIoA+Tg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tT3Mz-0004xX-RH for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2025 13:23:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jan 2025 18:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41493 X-GNU-PR-Package: emacs Original-Received: via spool by 41493-submit@debbugs.gnu.org id=B41493.173575573318981 (code B ref 41493); Wed, 01 Jan 2025 18:23:01 +0000 Original-Received: (at 41493) by debbugs.gnu.org; 1 Jan 2025 18:22:13 +0000 Original-Received: from localhost ([127.0.0.1]:39757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tT3MC-0004w5-Ow for submit@debbugs.gnu.org; Wed, 01 Jan 2025 13:22:13 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:49771) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tT3MA-0004vd-EE for 41493@debbugs.gnu.org; Wed, 01 Jan 2025 13:22:11 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 20908800C4; Wed, 1 Jan 2025 13:22:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1735755722; bh=XelOWfB91SYV1tE79Np3uDikK50upFv0pZ/DyGX88UQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DZtNAsw3zWLXHrFUT/TvxXaA5wLob7gpa//a09rYTSCyhg2Av5m5eOAzhH8ptWkYg EwAvHdXbO1uNnCW3jZzZZkgwoD4eLw2X5Pr325Fs3dp/bPLa/BGPsLdNmcXyQQ7mJl c8CakY2mf3BqBf7y4PPda4F35/iaT5uFRCr+dan9gdp+U3VzSIaSTm40NU0kw/UYiq hdRu8sa97+la2FaHMrzcpp6DZp7BRq6EM0QiDHO+kDcO1enhVrORrTRC9EwRE4jHw0 ncp8msxCnEp7e8NPj2hG9GkllbXAoHqYlVdPF3zthJLJI7wWzVQEarlwdg+hy/gsab RtI4Zjep2r2Xw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 18FFB806F8; Wed, 1 Jan 2025 13:22:02 -0500 (EST) Original-Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A12D01201DA; Wed, 1 Jan 2025 13:22:01 -0500 (EST) In-Reply-To: <87ed1npsbm.fsf@pub.pink> (john muhl's message of "Tue, 31 Dec 2024 13:26:21 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298068 Archived-At: --=-=-= Content-Type: text/plain Hi John, > 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. [...] > 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)) Hmm... IIUC the output we receive is a list of pairs made of sublists of the form either: (directory . <...>) (Last-Modified . <...>) or (file . <...>) (Last-Modified . <...>) (Format . <...>) (Title . <...>) ... IIUC when I wrote the code there were no such `Last-Modified` entries. We're interested in extracting a list of the files (where each file is represented by its alist), so I just stripped away all the `directory` entries and that was it. But now that `directory` can be followed by info about that directory (currently only `Last-Modified`), we should arguably be more careful to also remove everything between `directory` and the next `file` or `directory`. So I think the patch below is "more robust". WDYT? I also think it's a good opportunity to add some comments/docstrings because it took me a while to understand what this was trying to do. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=mpc.patch diff --git a/lisp/mpc.el b/lisp/mpc.el index ad11007f064..ca450fd959a 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -312,11 +312,11 @@ mpc--proc-alist-to-alists-starters (defun mpc--proc-alist-to-alists (alist) (cl-assert (or (null alist) (memq (caar alist) mpc--proc-alist-to-alists-starters))) - (let ((starter (caar alist)) + (let (;; (starter (caar alist)) (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)) @@ -638,15 +638,14 @@ mpc-cmd-find (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. + (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) --=-=-=--