* 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)
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.
(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
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)