]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/dired-aux.el (dired-do-revert-buffer): New defcustom (bug#48456).
authorJuri Linkov <juri@linkov.net>
Fri, 21 May 2021 18:31:48 +0000 (21:31 +0300)
committerJuri Linkov <juri@linkov.net>
Fri, 21 May 2021 18:31:48 +0000 (21:31 +0300)
(dired-do-create-files): Use it.

etc/NEWS
lisp/dired-aux.el

index 693d0c0026bd3b07bbdeef381bd067dfd276f121..acd7899b750c3a530f897c60377564b8ec9b65b5 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -748,6 +748,11 @@ If set to non-nil, Dired will dereference symbolic links when copying.
 This can be switched off on a per-usage basis by providing
 'dired-do-copy' with a 'C-u' prefix.
 
+*** New user option 'dired-do-revert-buffer'.
+Non-nil reverts the destination Dired buffer after preforming one
+of these operations: 'dired-do-copy', 'dired-do-rename',
+'dired-do-symlink', 'dired-do-hardlink'.
+
 *** New user option 'dired-mark-region' affects all Dired commands
 that mark files.  When non-nil and the region is active in Transient
 Mark mode, then Dired commands operate only on files in the active
index d57237f03838ccd57d405657a4c16a788490422f..0ac4e54bafed31524c8664682280ec4e6404a0e4 100644 (file)
@@ -2065,6 +2065,25 @@ ESC or `q' to not overwrite any of the remaining files,
               operation success-count))))
   (dired-move-to-filename))
 \f
+(defcustom dired-do-revert-buffer nil
+  "Automatically revert Dired buffers after `dired-do' operations.
+This option controls whether to refresh the directory listing in a
+Dired buffer that is the destination of one of these operations:
+`dired-do-copy', `dired-do-rename', `dired-do-symlink', `dired-do-hardlink'.
+If the value is t, always revert the Dired buffer updated in the result
+of these 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 +2187,12 @@ Optional arg HOW-TO determines how to treat the target.
           (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.