branch: master
commit 62a2c7ed34df2d7f0f63d1d44fdad926c10bc4bc
Author: Eric Danan <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-find-file): Improve copy and move actions
Start the new filename completion from the directory of the file to
copy or move instead of the initial directory from which
counsel-find-file was called. Also adapt the prompt to the action (was
not the case for the copy action).
Fixes #2053
---
counsel.el | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/counsel.el b/counsel.el
index a7b5343..fc44e31 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1747,11 +1747,12 @@ choose between `yes-or-no-p' and `y-or-n-p'; otherwise
default to
(defun counsel-find-file-copy (x)
"Copy file X."
- (let ((ivy-inhibit-action
- (lambda (new-name)
- (require 'dired-aux)
- (dired-copy-file x new-name 1))))
- (counsel-find-file)))
+ (require 'dired-aux)
+ (counsel--find-file-1 "Copy file to: "
+ ivy--directory
+ (lambda (new-name)
+ (dired-copy-file x new-name 1))
+ 'counsel-find-file-copy))
(defun counsel-find-file-delete (x)
"Delete file X."
@@ -1767,13 +1768,12 @@ choose between `yes-or-no-p' and `y-or-n-p'; otherwise
default to
(defun counsel-find-file-move (x)
"Move or rename file X."
- (ivy-read "Rename file to: " #'read-file-name-internal
- :matcher #'counsel--find-file-matcher
- :action (lambda (new-name)
- (require 'dired-aux)
- (dired-rename-file x new-name 1))
- :keymap counsel-find-file-map
- :caller 'counsel-find-file-move))
+ (require 'dired-aux)
+ (counsel--find-file-1 "Rename file to: "
+ ivy--directory
+ (lambda (new-name)
+ (dired-rename-file x new-name 1))
+ 'counsel-find-file-move))
(defun counsel-find-file-mkdir-action (_x)
"Create a directory from `ivy-text'."