From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#54636: dired fails to update subdirs when files are created/deleted/renamed Date: Wed, 30 Mar 2022 16:30:22 +0200 Message-ID: <87czi31p1l.fsf@gnu.org> References: <877d8b3d4w.fsf@igel.home> <87y20r1vys.fsf@igel.home> <87o81n1ue5.fsf@gnu.org> <835ynv8ti4.fsf@gnu.org> <87k0cb1rpa.fsf@gnu.org> <831qyj8rxl.fsf@gnu.org> 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="5085"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.7.12; emacs 29.0.50 Cc: 54636@debbugs.gnu.org, schwab@linux-m68k.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 30 16:42:28 2022 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 1nZZWl-0001DF-DX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Mar 2022 16:42:27 +0200 Original-Received: from localhost ([::1]:37902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZZWk-0005xJ-B6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Mar 2022 10:42:26 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZZWM-0005tw-Rc for bug-gnu-emacs@gnu.org; Wed, 30 Mar 2022 10:42:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZZWM-0004Wz-2N for bug-gnu-emacs@gnu.org; Wed, 30 Mar 2022 10:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZZWL-0003XV-Tc for bug-gnu-emacs@gnu.org; Wed, 30 Mar 2022 10:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Mar 2022 14:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54636 X-GNU-PR-Package: emacs Original-Received: via spool by 54636-submit@debbugs.gnu.org id=B54636.164865126713528 (code B ref 54636); Wed, 30 Mar 2022 14:42:01 +0000 Original-Received: (at 54636) by debbugs.gnu.org; 30 Mar 2022 14:41:07 +0000 Original-Received: from localhost ([127.0.0.1]:36665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZZVS-0003W8-Pr for submit@debbugs.gnu.org; Wed, 30 Mar 2022 10:41:07 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZZVQ-0003VX-Sz for 54636@debbugs.gnu.org; Wed, 30 Mar 2022 10:41:05 -0400 Original-Received: from [2001:470:142:3::e] (port=36216 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZZVL-0004Ql-26; Wed, 30 Mar 2022 10:40:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=1QkqeuY+SA08WYSmYzQLP2KSNl1JyhvOY4PBUSqujSg=; b=S55vbbaxrGjRNJ zy7aZoR9xJOZFmwsPS/aOIO/mnXmu0UhOSp+zOPFWsLaY/V/l9tqv4CsrdYl0/xePeoSYoZ6golId 0lj3FgqxoSWQYehlPema07zqodUchvgZbgRGdPtcb8TzTzfJYFcqD6GniN3/bpT7b6RoyV0uMBfkf WbWMmCLwN7XefoZyN+WZcVmD/9+s4muNzLoeSjCBPxjnnXX9h9lqqV3iu0h5/VErmY9A3Tmm+GS/i dZZoCLWx2PGJVp5ntBBKN3fUCOpUVDlesZfd1T7ciU4RVL1nJsSD2UB2IYtjSLHs3LkiwZ77pI7wg rUfvijYBMYrc9KmpS+8w==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:51363) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZZVK-0003UN-H7; Wed, 30 Mar 2022 10:40:58 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id E712D27C005A; Wed, 30 Mar 2022 10:40:56 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 30 Mar 2022 10:40:56 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeivddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvufffjgfkgggtsehmtderredtredtnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnhepve efvefhjeekieekueeljeevjefghffftdffuddtvedttdeufeevffdvfeduhfehnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhrnhdomh gvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeifeehvdel kedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Mar 2022 10:40:56 -0400 (EDT) In-reply-to: <831qyj8rxl.fsf@gnu.org> 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" Xref: news.gmane.io gmane.emacs.bugs:229115 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: Hi Eli, >> > I think I just fixed it there, please take a look. >> >> That's what I was about to do, too, but that's not right, too. > > Well, it fixes the regression. That's true. >> Say you have dired buffers for >> >> ~/ >> ~/foo/ >> ~/foo/bar/ >> >> and then delete ~/foo from inside the ~/ dired buffer. You'll be >> asked if the buffers for foo should be delete, too, and when you >> confirm, what is deleted are the buffers ~/ and ~/foo but ~/foo/bar >> persists. So the buffers are deleted downwards (to the root) instead >> of upwards which is wrong. > > This means your fix for the "ask" part is incomplete, and should be > improved. But that is a new feature in Emacs 28, so it is not a > catastrophe if it is imperfect. It's still a major annoyance since the feature is not opt-in. > Regressions in previously correct behavior are much worse. Of course. > Of course, if you can come up with a fix for the question-asking part > that makes it delete all the relevant buffers, and if that fix is safe > enough (a high bar at this late stage of the pretest), we can install > that on the release branch. Failing that, the fix for that will have > to wait till Emacs 28.2 at the very least. Here's a patch. I've created a separate cond-arm for the SUBDIRS case, so any callers which are not dired-clean-up-after-deletion (the only one setting SUBDIRS) are not affected. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=dired.patch diff --git a/lisp/dired.el b/lisp/dired.el index 75dcd33e67..972a0865f4 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2874,8 +2874,9 @@ dired-buffers-for-dir "Return a list of buffers for DIR (top level or in-situ subdir). If FILE is non-nil, include only those whose wildcard pattern (if any) matches FILE. -If SUBDIRS is non-nil, also include the dired buffers of -directories below DIR. +If SUBDIRS is non-nil, include the dired buffers of DIR and the +directories below DIR instead (but no dired buffers with in-situ +subdir DIR). The list is in reverse order of buffer creation, most recent last. As a side effect, killed dired buffers for DIR are removed from `dired-buffers'." @@ -2887,10 +2888,9 @@ dired-buffers-for-dir ((null (buffer-name buf)) ;; Buffer is killed - clean up: (setq dired-buffers (delq elt dired-buffers))) - ((dired-in-this-tree-p dir (car elt)) + ((and (null subdirs) (dired-in-this-tree-p dir (car elt))) (with-current-buffer buf - (when (and (or subdirs - (assoc dir dired-subdir-alist)) + (when (and (assoc dir dired-subdir-alist) (or (null file) (if (stringp dired-directory) (let ((wildcards (file-name-nondirectory @@ -2900,7 +2900,9 @@ dired-buffers-for-dir file))) (member (expand-file-name file dir) (cdr dired-directory))))) - (setq result (cons buf result))))))) + (setq result (cons buf result))))) + ((and subdirs (dired-in-this-tree-p (car elt) dir)) + (setq result (cons buf result))))) result)) (defun dired-glob-regexp (pattern) --=-=-= Content-Type: text/plain Can we agree it is safe enough? Bye, Tassilo --=-=-=--