* lisp/dired.el (dired-dwim-target): Add choice dired-dwim-target-next-visible
* 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)
This commit is contained in:
parent
99271ea8de
commit
5ddec1365c
3 changed files with 22 additions and 8 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue