From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fadi Moukayed Newsgroups: gmane.emacs.bugs Subject: bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer Date: Thu, 15 Jun 2023 13:10:25 +0200 Message-ID: References: <83h6r9t302.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16613"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64079@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 15 13:47:39 2023 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 1q9lRz-00047R-TD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Jun 2023 13:47:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9lRT-0007uX-HY; Thu, 15 Jun 2023 07:47:07 -0400 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 1q9lRQ-0007uJ-1x for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 07:47:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q9lRO-0003If-Ly for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 07:47:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q9lRO-00025D-IV for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 07:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Fadi Moukayed Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Jun 2023 11:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64079 X-GNU-PR-Package: emacs Original-Received: via spool by 64079-submit@debbugs.gnu.org id=B64079.16868295757942 (code B ref 64079); Thu, 15 Jun 2023 11:47:02 +0000 Original-Received: (at 64079) by debbugs.gnu.org; 15 Jun 2023 11:46:15 +0000 Original-Received: from localhost ([127.0.0.1]:46314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9lQc-000242-T8 for submit@debbugs.gnu.org; Thu, 15 Jun 2023 07:46:15 -0400 Original-Received: from mail-ed1-f43.google.com ([209.85.208.43]:58833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9ksF-000753-25 for 64079@debbugs.gnu.org; Thu, 15 Jun 2023 07:10:43 -0400 Original-Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-518b69d5b5dso2280823a12.1 for <64079@debbugs.gnu.org>; Thu, 15 Jun 2023 04:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686827437; x=1689419437; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/ULNByAYAFbFhJ66/Rf8pg1VqRKy97SsYoTlR2GPLZ8=; b=GHv3zUPpL3W7kJrGeOFHrtes+Quajw14r78mzloJSP/UJFkzBK08mcCHLSjCwXDVCh RRMXFCk2sImudd3AXDMwO+LcRt5czWu9hsufmkNuT7sTV8P4jG18at1vqMLQeYLSNM0W mTD/eu4PIA+vggu3Q3ooBaWJp9/zafUZMu7IsDC+IH2ZT3Mt4g/HgSPCr+I1wHfk3dxZ LKUCa2my3P15WlOahitdARyGXjA8mgHHA1sVg2rln2iwmNWW6L+KhxCVwP804eiKgdp4 ulLHZOCLbSUkTSghg/nLbGGchpL0Bgrjk69mD6VmYuuipe2X4Fh+T7Z4Ci8LAtu62gLn qssQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686827437; x=1689419437; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/ULNByAYAFbFhJ66/Rf8pg1VqRKy97SsYoTlR2GPLZ8=; b=ULOuj5Jn+jcPMZS0ocLsySjhFcsQppBcuhaxBtzWUwbVzimSKEvJ1X3ROl1i1MMjd7 oyhu8WIP4/U8Pmx+FZiIfVx91V54s07N8fC2tvi8MHmNBmsjCmuZHiNBjcmiRtTnFd39 ZgcaFrtaPiHAMPW3qyedvxNic4xGRFSjXrHWAia2q41Aqgs1jev5s3eRfijQ2ZrMrHgo +dW1bXVVYpHBZm7bGeB8gGmVzeCI5ESHNBYe9E2xUgn0ofH6nJB8BaJjOLRGDpbAbLNt ceUnWEheK0iG4S134pDXVLO+/8a4wVevKKkDZzfREUxTmLYFgNJC9ZjCI6NN4jK9JTe8 kTpw== X-Gm-Message-State: AC+VfDxXqgtvTIEIevzGgEOAAr8zU95X4/fSJM1LwHsm2uyqLd4RCb5W 1sYGTgvzjI4KAJdzXehPgPm4Uz2wWHKJTLdLPqg= X-Google-Smtp-Source: ACHHUZ4m0y2qWRA18OdLVlDGPly6C/yCCxpTe/dvhNR3Cf4E8y/DLLtWjxGPn3/Nt4o2a/oQXvKv/gvQFArEhLOhHVM= X-Received: by 2002:a17:907:e90:b0:982:8ec0:15a3 with SMTP id ho16-20020a1709070e9000b009828ec015a3mr2434487ejc.67.1686827436783; Thu, 15 Jun 2023 04:10:36 -0700 (PDT) In-Reply-To: <83h6r9t302.fsf@gnu.org> X-Mailman-Approved-At: Thu, 15 Jun 2023 07:46:13 -0400 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:263422 Archived-At: Hi Eli, Thanks a lot. Just tested your patch a few moments ago (with dired-kill-when-opening-new-dired-bufferset to t) and it fixes the issue. I also tested the default behavior (with dired-kill-when-opening-new-dired-buffer set to nil), and everything works as expected in that case as well. Cheers. Am Do., 15. Juni 2023 um 12:48 Uhr schrieb Eli Zaretskii : > > > From: Fadi Moukayed > > Date: Thu, 15 Jun 2023 10:54:27 +0200 > > > > 1. Start Emacs > > 2. Open a `dired' buffer, e.g. using C-x d > > 3. Use M-: and evaluate the expression `(define-key dired-mode-map [mouse-3] > > 'dired-mouse-find-file)' > > 4. Navigate a nested directory tree (e.g. a/b/c/d) in dired by right-clicking > > on the directory names. > > > > Expected behavior: > > > > Only a dired buffer for d is retained. > > > > Observed behavior: > > > > dired buffers a, b, c are created and retained in addition to d. > > > > Hints: > > > > `dired-mouse-find-file' needs to contain similar logic to > > `dired--find-possibly-alternative-file' for checking the customization > > variable, or needs to delegate to the latter function. > > Thanks. Does the patch below give good results? > > diff --git a/lisp/dired.el b/lisp/dired.el > index 4a4ecc9..de87530 100644 > --- a/lisp/dired.el > +++ b/lisp/dired.el > @@ -2765,10 +2765,11 @@ dired-mouse-find-file > The optional arguments FIND-FILE-FUNC and FIND-DIR-FUNC specify > functions to visit the file and directory, respectively. If > omitted or nil, these arguments default to `find-file' and `dired', > -respectively." > +respectively. If `dired-kill-when-opening-new-dired-buffer' is > +non-nil, FIND-DIR-FUNC defaults to `find-alternate-file' instead, > +so that the original Dired buffer is not kept." > (interactive "e") > (or find-file-func (setq find-file-func 'find-file)) > - (or find-dir-func (setq find-dir-func 'dired)) > (let (window pos file) > (save-excursion > (setq window (posn-window (event-end event)) > @@ -2776,6 +2777,12 @@ dired-mouse-find-file > (if (not (windowp window)) > (error "No file chosen")) > (set-buffer (window-buffer window)) > + (unless find-dir-func > + (setq find-dir-func > + (if (and dired-kill-when-opening-new-dired-buffer > + (< (length (get-buffer-window-list)) 2)) > + 'find-alternate-file > + 'dired))) > (goto-char pos) > (setq file (dired-get-file-for-visit))) > (if (file-directory-p file)