emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] change dired--find-possibly-alternative-file behaviour.


From: Felix
Subject: Re: [PATCH] change dired--find-possibly-alternative-file behaviour.
Date: Sun, 26 Feb 2023 08:01:01 +0100
User-agent: mu4e 1.9.3; emacs 30.0.50

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Felix <felix.dick@web.de>
>> Cc: emacs-devel@gnu.org
>> Date: Sun, 26 Feb 2023 07:32:27 +0100
>>
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> >> From: Felix <felix.dick@web.de>
>> >> Cc: emacs-devel@gnu.org
>> >> Date: Sun, 26 Feb 2023 07:07:10 +0100
>> >>
>> >>
>> >> Eli Zaretskii <eliz@gnu.org> writes:
>> >>
>> >> >> From: Felix <felix.dick@web.de>
>> >> >> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]