From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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:48:45 +0300 Message-ID: <83h6r9t302.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36774"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64079@debbugs.gnu.org To: Fadi Moukayed Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 15 12:49:11 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 1q9kXP-0009PM-8d for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Jun 2023 12:49:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9kXH-0005OT-Nd; Thu, 15 Jun 2023 06:49:03 -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 1q9kXG-0005OJ-HL for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 06:49:02 -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 1q9kXG-0004pg-8z for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 06:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q9kXG-0006V4-4i for bug-gnu-emacs@gnu.org; Thu, 15 Jun 2023 06:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Jun 2023 10:49: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.168682611224931 (code B ref 64079); Thu, 15 Jun 2023 10:49:02 +0000 Original-Received: (at 64079) by debbugs.gnu.org; 15 Jun 2023 10:48:32 +0000 Original-Received: from localhost ([127.0.0.1]:46265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9kWl-0006U2-Nr for submit@debbugs.gnu.org; Thu, 15 Jun 2023 06:48:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9kWj-0006TM-PC for 64079@debbugs.gnu.org; Thu, 15 Jun 2023 06:48:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9kWe-0004gR-I8; Thu, 15 Jun 2023 06:48:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0EhWf5SnGPl/aqhP0lJVhvMtyT22aljpIHaa8raHE/Q=; b=GlSA2iJzRk3H 9rMKsuhz3L1LFFOsKtG1h84YsarXUTkOFaJDr4BdONnQabnsCcmQu1L+eS7jgHbCOpmvtTT7R5yDJ n8YOxgfaV/no0/oPr8Tt4LwVXDgxhLPqW6B0SHnRIDbZ9796N/E5DgpTSlV9ExdPgTLaUiCf9G6yi 0JDGuMh9IC/frhlzHtANO0rLDIoIaqNCMEQl161+NM2KhEkAktLMbnJ9DaRE2XOWxWWy3oowcCjvT 4N2ni8O1xZGswq9PxjUvOPetgRSQU/f1TaqyHxDYTFY/L3PyOSg6WP4sDzPNEsQ/gH3vcN9XAKmU5 52vK71nZdYrlrY33xID/Fw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9kWd-0005L9-WB; Thu, 15 Jun 2023 06:48:24 -0400 In-Reply-To: (message from Fadi Moukayed on Thu, 15 Jun 2023 10:54:27 +0200) 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:263420 Archived-At: > 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)