From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#48456: Revert Dired after copy/rename Date: Wed, 19 May 2021 19:18:37 +0300 Organization: LINKOV.NET Message-ID: <87v97en1tm.fsf@mail.linkov.net> References: <87v97j1xih.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1306"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) To: 48456@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 19 18:57:04 2021 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 1ljPVF-0000BI-K8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 18:57:01 +0200 Original-Received: from localhost ([::1]:38362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljPVE-0008Mx-GL for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 12:57:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljP83-0007ja-BQ for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:33:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljP82-0006KK-HG for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:33:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ljP82-0000Ey-DE for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 May 2021 16:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48456 X-GNU-PR-Package: emacs Original-Received: via spool by 48456-submit@debbugs.gnu.org id=B48456.1621441924824 (code B ref 48456); Wed, 19 May 2021 16:33:02 +0000 Original-Received: (at 48456) by debbugs.gnu.org; 19 May 2021 16:32:04 +0000 Original-Received: from localhost ([127.0.0.1]:60571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljP76-0000DE-7i for submit@debbugs.gnu.org; Wed, 19 May 2021 12:32:04 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:30909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljP73-0000C4-Gf for 48456@debbugs.gnu.org; Wed, 19 May 2021 12:32:02 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 8DBEF240008 for <48456@debbugs.gnu.org>; Wed, 19 May 2021 16:31:53 +0000 (UTC) In-Reply-To: <87v97j1xih.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 16 May 2021 00:45:58 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:206903 Archived-At: --=-=-= Content-Type: text/plain > This has been a problem for a long time. > Every time after copying a file to another directory, > there is a need to switch to the Dired buffer with the copied file, > and revert it manually by typing 'g' to restore the correct sorting order, > because the copied file is inserted where point was located, but not > where it should be according to the Dired sorting order. > > This patch reverts the target buffer only when dired-auto-revert-buffer > is customized to t. It seems better to create a new option: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-do-revert-buffer.patch diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index eb43ab187d..5df4d6b206 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2065,6 +2065,24 @@ dired-create-files operation success-count)))) (dired-move-to-filename)) +(defcustom dired-do-revert-buffer nil + "Automatically revert Dired buffers after some operations. +This option controls whether to refresh the directory listing in a +Dired buffer that is the destination of copy/rename/symlink/hardlink operations. +If the value is t, always revert the Dired buffer updated in the result +of Dired operations. +If the value is a function, it is called with the destination directory name +as a single argument, and the buffer is reverted after Dired operations +if the function returns non-nil." + :type '(choice + (const :tag "Don't revert" nil) + (const :tag "Always revert destination directory" t) + (const :tag "Revert only local Dired buffers" + (lambda (dir) (not (file-remote-p dir)))) + (function :tag "Predicate function")) + :group 'dired + :version "28.1") + (defun dired-do-create-files (op-symbol file-creator operation arg &optional marker-char op1 how-to) @@ -2168,7 +2186,12 @@ dired-do-create-files (lambda (from) (expand-file-name (file-name-nondirectory from) target)) (lambda (_from) target)) - marker-char)))) + marker-char) + (when (or (eq dired-do-revert-buffer t) + (and (functionp dired-do-revert-buffer) + (funcall dired-do-revert-buffer target))) + (dired-fun-in-all-buffers (file-name-directory target) nil + #'revert-buffer))))) ;; Read arguments for a marked-files command that wants a file name, ;; perhaps popping up the list of marked files. --=-=-=--