Skip to content
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

Improvements to some counsel-find-file actions #2053

Closed
wants to merge 3 commits into from

Conversation

@ericdanan
Copy link
Contributor

@ericdanan ericdanan commented May 3, 2019

See commit messages.

Copy link
Collaborator

@basil-conto basil-conto left a comment

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

Loading

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

@basil-conto basil-conto May 3, 2019

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.

Loading

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

@basil-conto basil-conto May 3, 2019

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.

Loading

counsel.el Outdated
(counsel--find-file-1 "Copy file to: "
ivy--directory
(lambda (new-name)
(require 'dired-aux)
Copy link
Collaborator

@basil-conto basil-conto May 3, 2019

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.

Loading

counsel.el Outdated
(counsel--find-file-1 "Rename file to: "
ivy--directory
(lambda (new-name)
(require 'dired-aux)
Copy link
Collaborator

@basil-conto basil-conto May 3, 2019

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.

Loading

ericdanan added 3 commits May 3, 2019
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

@ericdanan ericdanan commented May 3, 2019

Thanks for the review, I applied your suggestions.

Loading

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 6, 2019

Thanks, all.

Loading

@ericdanan ericdanan deleted the findfile branch May 6, 2019
astoff added a commit to astoff/swiper that referenced this issue 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 added a commit to astoff/swiper that referenced this issue 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
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants