-
-
Notifications
You must be signed in to change notification settings - Fork 339
Improvements to some counsel-find-file actions #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I only have some minor comments. I also noticed a typo in the third commit's message:
Start the new filename completion from the direcctory
counsel.el
Outdated
(make-directory (expand-file-name ivy-text ivy--directory)) | ||
(unless (eq ivy-exit 'done) | ||
(with-selected-window (active-minibuffer-window) | ||
(ivy--cd (expand-file-name ivy-text ivy--directory))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safer to check that active-minibuffer-window
does not return nil
:
(defun counsel-find-file-mkdir-action (_x)
(let ((dir (expand-file-name ivy-text ivy--directory))
(win (and (not (eq ivy-exit 'done))
(active-minibuffer-window))))
(make-directory dir)
(when win (with-selected-window win (ivy--cd dir)))))
Please also add a docstring. Thanks.
counsel.el
Outdated
@@ -1754,7 +1754,9 @@ choose between `yes-or-no-p' and `y-or-n-p'; otherwise default to | |||
(counsel--yes-or-no-p "Delete %s? " x)) | |||
(dired-delete-file x dired-recursive-deletes delete-by-moving-to-trash) | |||
(dired-clean-up-after-deletion x) | |||
(ivy--reset-state ivy-last))) | |||
(unless (eq ivy-exit 'done) | |||
(with-selected-window (active-minibuffer-window) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto re: active-minibuffer-window
returning nil
.
counsel.el
Outdated
(counsel--find-file-1 "Copy file to: " | ||
ivy--directory | ||
(lambda (new-name) | ||
(require 'dired-aux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The require
should be moved to the toplevel of the function, I think.
counsel.el
Outdated
(counsel--find-file-1 "Rename file to: " | ||
ivy--directory | ||
(lambda (new-name) | ||
(require 'dired-aux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto re: hoisting require
out of the action function.
Make ivy-call cd into created directory.
Make ivy-call stay in directory and update minibuffer (previously it would go back to the initial directory from which counsel-find-file was called).
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).
Thanks for the review, I applied your suggestions. |
Thanks, all. |
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 abo-abo#2053
See commit messages.