* lisp/dired.el (dired-dwim-target): Add new choices (bug#35385)
* lisp/dired.el (dired-dwim-target): Add choices dired-dwim-target-next and dired-dwim-target-recent. * lisp/dired-aux.el (dired-dwim-target-next) (dired-dwim-target-recent): New functions. (dired-dwim-target-directories): Call either of them. * doc/emacs/dired.texi (Operating on Files): Mention new preferences in dired-dwim-target.
This commit is contained in:
parent
4cccf7659a
commit
d0351f4d20
4 changed files with 38 additions and 10 deletions
|
@ -654,10 +654,12 @@ commands, use the same conventions to decide which files to work on.
|
|||
Commands which ask for a destination directory, such as those which
|
||||
copy and rename files or create links for them, try to guess the default
|
||||
target directory for the operation. Normally, they suggest the Dired
|
||||
buffer's default directory, but if the variable @code{dired-dwim-target}
|
||||
is non-@code{nil}, and if there is another Dired buffer displayed in one
|
||||
of the most recently used windows, that other buffer's directory is
|
||||
suggested instead.
|
||||
buffer's default directory, but if the option @code{dired-dwim-target}
|
||||
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.
|
||||
|
||||
Here are the file-manipulating Dired commands that operate on files.
|
||||
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -852,8 +852,8 @@ pipes, block devices and character devices.
|
|||
directories in the destination.
|
||||
|
||||
+++
|
||||
*** The non-nil value of 'dired-dwim-target' uses one of the most recently
|
||||
visited windows with a Dired buffer instead of the next window.
|
||||
*** 'dired-dwim-target' can be customized to prefer either the next window,
|
||||
or one of the most recently visited windows with a Dired buffer.
|
||||
|
||||
*** When the new user option 'dired-vc-rename-file' is non-nil,
|
||||
Dired performs file renaming using underlying version control system.
|
||||
|
|
|
@ -1993,6 +1993,22 @@ Optional arg HOW-TO determines how to treat the target.
|
|||
(format prompt (dired-mark-prompt arg files)) dir default))
|
||||
|
||||
(defun dired-dwim-target-directories ()
|
||||
(cond ((functionp dired-dwim-target)
|
||||
(funcall dired-dwim-target))
|
||||
(dired-dwim-target
|
||||
(dired-dwim-target-next))))
|
||||
|
||||
(defun dired-dwim-target-next ()
|
||||
;; Return directories from all next visible 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))))
|
||||
|
||||
(defun dired-dwim-target-recent ()
|
||||
;; Return directories from all visible windows with dired-mode buffers
|
||||
;; ordered by most-recently-used.
|
||||
(mapcar #'cdr (sort (mapcan (lambda (w)
|
||||
|
|
|
@ -185,12 +185,22 @@ If a character, new links are unconditionally marked with that character."
|
|||
|
||||
(defcustom dired-dwim-target nil
|
||||
"If non-nil, Dired tries to guess a default target directory.
|
||||
This means: if there is a Dired buffer displayed in one of the most
|
||||
recently selected windows, use its current directory, instead of this
|
||||
Dired buffer's current directory.
|
||||
This means: if there is a Dired buffer displayed in some window,
|
||||
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.
|
||||
|
||||
The target is used in the prompt for file copy, rename etc."
|
||||
:type 'boolean
|
||||
:type '(choice
|
||||
(const :tag "No guess" nil)
|
||||
(function-item :tag "Prefer next windows"
|
||||
dired-dwim-target-next)
|
||||
(function-item :tag "Prefer most recently used windows"
|
||||
dired-dwim-target-recent)
|
||||
(function :tag "Your function")
|
||||
(other :tag "Try to guess" t))
|
||||
:group 'dired)
|
||||
|
||||
(defcustom dired-copy-preserve-time t
|
||||
|
|
Loading…
Add table
Reference in a new issue