unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Felix <felix.dick@web.de>
To: emacs-devel <emacs-devel@gnu.org>
Subject: [PATCH] change dired--find-possibly-alternative-file behaviour.
Date: Sat, 25 Feb 2023 20:43:57 +0100	[thread overview]
Message-ID: <87mt51o5bu.fsf@web.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]


I find dired--find-possibly-alternative-file a bit
confusing if dired-kill-when-opening-new-dired-buffer is set to t.

It's fine if the active window is the only window that shows that dired
buffer, but if there are multiple windows showing dired buffers, it's
likely that the user wanted to have those windows showing dired buffers.
If those buffers happen to show the same directory, opening another
directory with dired-find-file will kill the buffer, and change the
shown buffer in both windows.

Before dired-kill-when-opening-new-dired-buffer, to copy/move a file to
another directory, i could open a dired buffer, split the window, in
one of the windows (both showing the same dired buffer) navigate to
another directory and copy the file (with the dired-dwim-target).

In my personal configuration, i changed
dired--find-possibly-alternative-file to not kill the buffer if
it's shown in another window. I'm not shure if this would fit
every workflow, but for me it feels more logical.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired.patch --]
[-- Type: text/x-patch, Size: 570 bytes --]

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))

             reply	other threads:[~2023-02-25 19:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 19:43 Felix [this message]
2023-02-26  5:26 ` [PATCH] change dired--find-possibly-alternative-file behaviour Eli Zaretskii
2023-02-26  6:07   ` Felix
2023-02-26  6:29     ` Eli Zaretskii
2023-02-26  6:32       ` Felix
2023-02-26  7:00         ` Eli Zaretskii
2023-02-26  7:01           ` Felix
2023-02-26  7:22             ` Felix
2023-02-26  8:10               ` Eli Zaretskii
2023-02-26 13:14                 ` Felix
2023-02-28 14:12                   ` Eli Zaretskii
2023-02-26  8:09             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt51o5bu.fsf@web.de \
    --to=felix.dick@web.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).