From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] change dired--find-possibly-alternative-file behaviour. Date: Sun, 26 Feb 2023 08:01:01 +0100 Message-ID: <87lekkewfp.fsf@web.de> References: <87mt51o5bu.fsf@web.de> <83ttz9j8up.fsf@gnu.org> <87y1olgdca.fsf@web.de> <83h6v9j5xm.fsf@gnu.org> <87ttz9gceo.fsf@web.de> <83bklgkj2h.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19700"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.3; emacs 30.0.50 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 26 08:12:39 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pWBD5-0004tE-8T for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Feb 2023 08:12:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWBCD-0004B4-NE; Sun, 26 Feb 2023 02:11:47 -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 1pWBC5-0004Ah-GN for emacs-devel@gnu.org; Sun, 26 Feb 2023 02:11:40 -0500 Original-Received: from mout.web.de ([212.227.17.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWBC1-0006iG-LG; Sun, 26 Feb 2023 02:11:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1677395491; i=felix.dick@web.de; bh=I8vdtWiG0hjmpxwzBQLurXxWQ24M4rYIql7KLCvj36s=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:Date:In-reply-to; b=YdsQnTbKndsDrwVrzT9RtMaO24VBapXY9O04S+v4hPoVDpVjd2V93AwjbXtPPL8Wb 640wsIQrDJ1x/erU59S0eS4wj1tSwjy6FJq/AgzfhMefIVSo/FpmWSccCedi1DIFJV 5Zpuyd7f8ow4E2jOKGCt78kZ+OUMU6ICJVbLxFu8qIq1e8HxYONpw6ivAQhv6jyQIA l3Dv/2RapL3HPnITT5Nh36PqXCl9jCx/ImKtq75ssS5qCqivKDeMRihjenxN39nvvP Rlg68PQ1IAh/Oj8lbQz+xefxPJcly/D1mjJ2tEOmAqNJeRnTkDTViTNJ1nmfneOp3T euCSYD4qZ5GnQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from felix-lifebooka531.web.de ([95.91.210.207]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MbkWK-1ovTKf0bOg-00dMc7; Sun, 26 Feb 2023 08:11:31 +0100 In-reply-to: <83bklgkj2h.fsf@gnu.org> X-Provags-ID: V03:K1:9waYPNxAeVqj4+aJa/bD7840TbstqX16+39g/971dHsYhAnq4EE 6n8TDGh97wiyEAC/BOMJHv1bmx723GgnTY8BIhBZ9vprXHE+k9lIHD2eQBNMKtRRAOFX+LW 8dH6LWZwt/pavqS1gJAcMn/R1GUK0B43hAhvgcAtfRf/YC3qQmGE8GxAS2pPnkddZb6B7ma GbF9WD+IglVryfaJ2J3ww== UI-OutboundReport: notjunk:1;M01:P0:UOfxxWBEEWI=;RkeoEVBagiLT1URvoA+vFd+/mjg VKoYOvvmHkXK8/7gt5XHBfTSOpaR+9B2BPhSO0+YcpheTONTRSAC4NJkL15t1K0B2Dst2X8VH WAeT+9Pv1CNtyYw02PQHbbMUT8qjseXQHijQk7Hnx0eHWLbqJphLKx0EsfQ/w6yrKOy5GKXp5 +9NADwSS1OUx2a8YF31TW32hqBv8/hbdoQ6IhrC7NSJhun1T44GVrzteIx3oHuChMaPJD2/AM DeaRuTn6aBO2puDqPFaW+gXWhCpmUPXs1d+pp72UieUP6/ExQPhQHG/P9K3v9/GltaHwE1u4a GYYjh9sWGlJebM5Twio98K0VXK5BJLHss5/dPME11DPkjREtV8xCdVdnff+SEaf7QyC9YYNyf 2zZka7XoPXQz7hxBA9i3dxtHe62tOM1YMSGWY8oCS+eWyZ+4tog9IO1XnVxzaAZhNVXHMU5Zj Wc8TunRMppXfMZj1bZXw5l4AaRDAkNXoEYT7MCkPoa2KKD8FWDeSAPotjew1m2nG1ZnZK3mXu rxh17E3fp9swFmvZZ6P8NRl1a7Rw26FxAvMUOCbu5MjzC2pGuRLlfi1HoZbWsFAT0t9PNeJX3 SLDpR8JPlurkKB+SMkAVUYtO8LFHYUogf5TVtwTiBxc7HWnzzUGqZam+fcTuEzBRnaFHz0RBs FAAl02+LTW0yHIa8snp4XHk3K8ZlwubFbPRYmq5FBQfscD2BNRagYVMRwQRFjHv9XTs7/WAnB RGnKBXAeqRHa7HHm+cQRSgnUIZciL7wPlqkT0sgiDZ3A8oYuvLgKUFdRG9dGZESjYhpxV0TM Received-SPF: pass client-ip=212.227.17.11; envelope-from=felix.dick@web.de; helo=mout.web.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303815 Archived-At: Eli Zaretskii writes: >> From: Felix >> Cc: emacs-devel@gnu.org >> Date: Sun, 26 Feb 2023 07:32:27 +0100 >> >> >> Eli Zaretskii writes: >> >> >> From: Felix >> >> Cc: emacs-devel@gnu.org >> >> Date: Sun, 26 Feb 2023 07:07:10 +0100 >> >> >> >> >> >> Eli Zaretskii writes: >> >> >> >> >> From: Felix >> >> >> Date: Sat, 25 Feb 2023 20:43:57 +0100 >> >> >> >> >> >> diff --git a/lisp/dired.el b/lisp/dired.el >> >> >> index 76499d0f520..620508bef4f 100644 >> >> >> --- a/lisp/dired.el >> >> >> +++ b/lisp/dired.el >> >> >> @@ -2728,7 +2728,8 @@ dired-find-file >> >> >> (defun dired--find-possibly-alternative-file (file) >> >> >> "Find FILE, but respect `dired-kill-when-opening-new-dired-buffer'." >> >> >> (if (and dired-kill-when-opening-new-dired-buffer >> >> >> - (file-directory-p file)) >> >> >> + (file-directory-p file) >> >> >> + (= (length (get-buffer-window-list)) 1)) >> >> >> (progn >> >> >> (set-buffer-modified-p nil) >> >> >> (dired--find-file #'find-alternate-file file)) >> >> > >> >> > What if get-buffer-window-list returns nil? >> >> >> >> The optional argument BUFFER-OR-NAME of get-buffer-window-list defaults >> >> to the current buffer, shouldn't that garantee that it never returns >> >> nil? >> > >> > Only if the current buffer is displayed in some window. >> >> If get-buffer-window-list returns nil for any case, (length nil) returns 0. >> In that case the if condition is false and dired--find-file will not >> kill any buffer. >> Is there a possible case where the function is called from dired buffer, >> and get-buffer-window-list returns nil? >> In that case the buffer would stay alive! >> >> dired--find-possibly-alternative-file is only used in 2 places >> dired-find-file and in dired-up-directory. >> I thought those functions are only useful inside dired buffer windows. > > I just asked that question to make sure we are not introducing a > regression here. If you are certain that situation cannot cause any > trouble, I'm okay with that conclusion. Just to be absolutely save, (= (length (get-buffer-window-list)) 1)) could be changed to (> (length (get-buffer-window-list)) 1)) >> I thought those functions are only useful inside dired buffer windows. is that not the case? If not (length (get-buffer-window-list)) will count the windows that are displaying the current buffer whatever that is, and kill or not kill a dired buffer depending on the result.