[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5ddec13: * lisp/dired.el (dired-dwim-target): Add choice dired-dw
From: |
Juri Linkov |
Subject: |
master 5ddec13: * lisp/dired.el (dired-dwim-target): Add choice dired-dwim-target-next-visible |
Date: |
Sat, 16 Nov 2019 17:06:27 -0500 (EST) |
branch: master
commit 5ddec1365c1594b2a5e13383ed6acefb5098947d
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>
* 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)
---
doc/emacs/dired.texi | 5 ++++-
lisp/dired-aux.el | 12 ++++++++----
lisp/dired.el | 13 ++++++++++---
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 8fab508..d186351 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -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.
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 6fcb074..4d7abd1 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -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
diff --git a/lisp/dired.el b/lisp/dired.el
index 009018f..6523e487 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5ddec13: * lisp/dired.el (dired-dwim-target): Add choice dired-dwim-target-next-visible,
Juri Linkov <=