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.devel Subject: Re: [PATCH] change dired--find-possibly-alternative-file behaviour. Date: Sun, 26 Feb 2023 09:00:06 +0200 Message-ID: <83bklgkj2h.fsf@gnu.org> References: <87mt51o5bu.fsf@web.de> <83ttz9j8up.fsf@gnu.org> <87y1olgdca.fsf@web.de> <83h6v9j5xm.fsf@gnu.org> <87ttz9gceo.fsf@web.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5645"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Felix Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 26 08:00:40 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 1pWB1T-0001Kt-UT for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Feb 2023 08:00:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWB0u-0001oY-I7; Sun, 26 Feb 2023 02:00: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 1pWB0t-0001oF-4x for emacs-devel@gnu.org; Sun, 26 Feb 2023 02:00:03 -0500 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 1pWB0s-0004Td-PM; Sun, 26 Feb 2023 02:00:02 -0500 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=HG4pAmUTS3RfP22NG/neXyN8ogG6HfWk7Jp+jn6x23A=; b=RtHmjf2KMp1v PSrG4eI6s3X6adv1SO/h/NTLuTbqZ6h6fYXpMKEzs7v1p7X6q4dZynZdDJpmVpIOPrB0lVlqNyhUO s/6ZVb5vEPn8QdEw2JH57qLsy0+TldkqTJJ1A556vo8/fyfa5I2xRoNYR7NriqFM6PuqJD7k6vjih K6K5r7Lr9ApmFig3KHlm2//dsnLnVHqCnqDetOm3Rs+yMg37jD8vravMmwNSB+ppMyXwaNO+5NbOH SZrzG8AIFKoLjsvHKhlujgV+IiJU2swBHj+ZBjP8wIqDF7m6GCNXil8rSQKypfPZrCvvIOFUP41hh fMgUC3WRU/szO0LweZiYkQ==; 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 1pWB0r-0002qR-T8; Sun, 26 Feb 2023 02:00:02 -0500 In-Reply-To: <87ttz9gceo.fsf@web.de> (message from Felix on Sun, 26 Feb 2023 07:32:27 +0100) 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:303814 Archived-At: > 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.