]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/dired.el (dired-dwim-target): Add choice dired-dwim-target-next-visible
authorJuri Linkov <juri@linkov.net>
Sat, 16 Nov 2019 22:06:16 +0000 (00:06 +0200)
committerJuri Linkov <juri@linkov.net>
Sat, 16 Nov 2019 22:06:16 +0000 (00:06 +0200)
* lisp/dired-aux.el (dired-dwim-target-next): Add arg ALL-FRAMES.
(dired-dwim-target-next-visible): New function.

* doc/emacs/dired.texi (Operating on Files): Describe function value
of dired-dwim-target.  (Bug#35385)

doc/emacs/dired.texi
lisp/dired-aux.el
lisp/dired.el

index 8fab508dea6c46f3ea7ce1046b80398ce586db95..d1863510d456de215dc9ac5cd3bad3c3a256759a 100644 (file)
@@ -659,7 +659,10 @@ is non-@code{nil}, and if there is another Dired buffer displayed in
 some window, that other buffer's directory is suggested instead.
 You can customize @code{dired-dwim-target} to prefer either the next
 window with a Dired buffer, or the most recently used window with
-a Dired buffer.
+a Dired buffer, or to use any other function.  When the value is
+a function, it will be called with no arguments and is expected to
+return a list of directories which will be used as defaults
+(i.e. default target and ``future history'').
 
   Here are the file-manipulating Dired commands that operate on files.
 
index 6fcb074f6a15955ab78a96573a25a43a19bea00f..4d7abd1ef6f0fa9a77d295466eb3fb3a2fc795b1 100644 (file)
@@ -1999,15 +1999,19 @@ Optional arg HOW-TO determines how to treat the target.
         (dired-dwim-target
          (dired-dwim-target-next))))
 
-(defun dired-dwim-target-next ()
-  ;; Return directories from all next visible windows with dired-mode buffers.
+(defun dired-dwim-target-next (&optional all-frames)
+  ;; Return directories from all next windows with dired-mode buffers.
   (mapcan (lambda (w)
             (with-current-buffer (window-buffer w)
               (when (eq major-mode 'dired-mode)
                 (list (dired-current-directory)))))
           (delq (selected-window) (window-list-1
-                                   (next-window nil 'nomini 'visible)
-                                   'nomini 'visible))))
+                                   (next-window nil 'nomini all-frames)
+                                   'nomini all-frames))))
+
+(defun dired-dwim-target-next-visible ()
+  ;; Return directories from all next visible windows with dired-mode buffers.
+  (dired-dwim-target-next 'visible))
 
 (defun dired-dwim-target-recent ()
   ;; Return directories from all visible windows with dired-mode buffers
index 009018fafe55acf3d51302511bdf968ea2bc69a0..6523e4871259a17a29969792aa7eea9fd34784f9 100644 (file)
@@ -190,16 +190,23 @@ use its current directory, instead of this Dired buffer's
 current directory.
 
 You can customize it to prefer either the next window with a Dired buffer,
-or the most recently used window with a Dired buffer.
+or the most recently used window with a Dired buffer, or to use any other
+function.  When the value is a function, it will be called with no
+arguments and is expected to return a list of directories which will
+be used as defaults (i.e. default target and \"future history\")
+(though, `dired-dwim-target-defaults' might modify it a bit).
+The value t prefers the next windows on the same frame.
 
 The target is used in the prompt for file copy, rename etc."
   :type '(choice
           (const :tag "No guess" nil)
-          (function-item :tag "Prefer next windows"
+          (function-item :tag "Prefer next windows on the same frame"
                          dired-dwim-target-next)
+          (function-item :tag "Prefer next windows on visible frames"
+                         dired-dwim-target-next-visible)
           (function-item :tag "Prefer most recently used windows"
                          dired-dwim-target-recent)
-          (function :tag "Your function")
+          (function :tag "Custom function")
           (other :tag "Try to guess" t))
   :group 'dired)