Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

ericdanan
Copy link
Contributor

See commit messages.

Copy link
Collaborator

@basil-conto basil-conto left a 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)))))
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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.

ericdanan added 3 commits May 3, 2019 15:57
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).
@ericdanan
Copy link
Contributor Author

Thanks for the review, I applied your suggestions.

@abo-abo
Copy link
Owner

abo-abo commented May 6, 2019

Thanks, all.

@ericdanan ericdanan deleted the findfile branch May 6, 2019 11:12
astoff pushed a commit to astoff/swiper that referenced this pull request Jan 1, 2021
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
astoff pushed a commit to astoff/swiper that referenced this pull request Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants