diff options
| author | Juri Linkov | 2019-11-12 23:21:14 +0200 |
|---|---|---|
| committer | Juri Linkov | 2019-11-12 23:21:14 +0200 |
| commit | d0351f4d2010e3e8f3ada04b045dede10f110d7f (patch) | |
| tree | e7fa73d650e3149372ec15bc98acc1dfe0b9c01c /lisp | |
| parent | 4cccf7659a4767274b383e5fc820e27391988cc7 (diff) | |
| download | emacs-d0351f4d2010e3e8f3ada04b045dede10f110d7f.tar.gz emacs-d0351f4d2010e3e8f3ada04b045dede10f110d7f.zip | |
* 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/dired-aux.el | 16 | ||||
| -rw-r--r-- | lisp/dired.el | 18 |
2 files changed, 30 insertions, 4 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 184b507e1de..9f34b2afe99 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -1993,6 +1993,22 @@ Optional arg HOW-TO determines how to treat the target. | |||
| 1993 | (format prompt (dired-mark-prompt arg files)) dir default)) | 1993 | (format prompt (dired-mark-prompt arg files)) dir default)) |
| 1994 | 1994 | ||
| 1995 | (defun dired-dwim-target-directories () | 1995 | (defun dired-dwim-target-directories () |
| 1996 | (cond ((functionp dired-dwim-target) | ||
| 1997 | (funcall dired-dwim-target)) | ||
| 1998 | (dired-dwim-target | ||
| 1999 | (dired-dwim-target-next)))) | ||
| 2000 | |||
| 2001 | (defun dired-dwim-target-next () | ||
| 2002 | ;; Return directories from all next visible windows with dired-mode buffers. | ||
| 2003 | (mapcan (lambda (w) | ||
| 2004 | (with-current-buffer (window-buffer w) | ||
| 2005 | (when (eq major-mode 'dired-mode) | ||
| 2006 | (list (dired-current-directory))))) | ||
| 2007 | (delq (selected-window) (window-list-1 | ||
| 2008 | (next-window nil 'nomini 'visible) | ||
| 2009 | 'nomini 'visible)))) | ||
| 2010 | |||
| 2011 | (defun dired-dwim-target-recent () | ||
| 1996 | ;; Return directories from all visible windows with dired-mode buffers | 2012 | ;; Return directories from all visible windows with dired-mode buffers |
| 1997 | ;; ordered by most-recently-used. | 2013 | ;; ordered by most-recently-used. |
| 1998 | (mapcar #'cdr (sort (mapcan (lambda (w) | 2014 | (mapcar #'cdr (sort (mapcan (lambda (w) |
diff --git a/lisp/dired.el b/lisp/dired.el index 9d0b13e2279..009018fafe5 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -185,12 +185,22 @@ If a character, new links are unconditionally marked with that character." | |||
| 185 | 185 | ||
| 186 | (defcustom dired-dwim-target nil | 186 | (defcustom dired-dwim-target nil |
| 187 | "If non-nil, Dired tries to guess a default target directory. | 187 | "If non-nil, Dired tries to guess a default target directory. |
| 188 | This means: if there is a Dired buffer displayed in one of the most | 188 | This means: if there is a Dired buffer displayed in some window, |
| 189 | recently selected windows, use its current directory, instead of this | 189 | use its current directory, instead of this Dired buffer's |
| 190 | Dired buffer's current directory. | 190 | current directory. |
| 191 | |||
| 192 | You can customize it to prefer either the next window with a Dired buffer, | ||
| 193 | or the most recently used window with a Dired buffer. | ||
| 191 | 194 | ||
| 192 | The target is used in the prompt for file copy, rename etc." | 195 | The target is used in the prompt for file copy, rename etc." |
| 193 | :type 'boolean | 196 | :type '(choice |
| 197 | (const :tag "No guess" nil) | ||
| 198 | (function-item :tag "Prefer next windows" | ||
| 199 | dired-dwim-target-next) | ||
| 200 | (function-item :tag "Prefer most recently used windows" | ||
| 201 | dired-dwim-target-recent) | ||
| 202 | (function :tag "Your function") | ||
| 203 | (other :tag "Try to guess" t)) | ||
| 194 | :group 'dired) | 204 | :group 'dired) |
| 195 | 205 | ||
| 196 | (defcustom dired-copy-preserve-time t | 206 | (defcustom dired-copy-preserve-time t |