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 | |
| 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.
| -rw-r--r-- | doc/emacs/dired.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 16 | ||||
| -rw-r--r-- | lisp/dired.el | 18 |
4 files changed, 38 insertions, 10 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index c32255a86db..8fab508dea6 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi | |||
| @@ -654,10 +654,12 @@ commands, use the same conventions to decide which files to work on. | |||
| 654 | Commands which ask for a destination directory, such as those which | 654 | Commands which ask for a destination directory, such as those which |
| 655 | copy and rename files or create links for them, try to guess the default | 655 | copy and rename files or create links for them, try to guess the default |
| 656 | target directory for the operation. Normally, they suggest the Dired | 656 | target directory for the operation. Normally, they suggest the Dired |
| 657 | buffer's default directory, but if the variable @code{dired-dwim-target} | 657 | buffer's default directory, but if the option @code{dired-dwim-target} |
| 658 | is non-@code{nil}, and if there is another Dired buffer displayed in one | 658 | is non-@code{nil}, and if there is another Dired buffer displayed in |
| 659 | of the most recently used windows, that other buffer's directory is | 659 | some window, that other buffer's directory is suggested instead. |
| 660 | suggested instead. | 660 | You can customize @code{dired-dwim-target} to prefer either the next |
| 661 | window with a Dired buffer, or the most recently used window with | ||
| 662 | a Dired buffer. | ||
| 661 | 663 | ||
| 662 | Here are the file-manipulating Dired commands that operate on files. | 664 | Here are the file-manipulating Dired commands that operate on files. |
| 663 | 665 | ||
| @@ -852,8 +852,8 @@ pipes, block devices and character devices. | |||
| 852 | directories in the destination. | 852 | directories in the destination. |
| 853 | 853 | ||
| 854 | +++ | 854 | +++ |
| 855 | *** The non-nil value of 'dired-dwim-target' uses one of the most recently | 855 | *** 'dired-dwim-target' can be customized to prefer either the next window, |
| 856 | visited windows with a Dired buffer instead of the next window. | 856 | or one of the most recently visited windows with a Dired buffer. |
| 857 | 857 | ||
| 858 | *** When the new user option 'dired-vc-rename-file' is non-nil, | 858 | *** When the new user option 'dired-vc-rename-file' is non-nil, |
| 859 | Dired performs file renaming using underlying version control system. | 859 | Dired performs file renaming using underlying version control system. |
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 |