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

How to know what is the default action #1774

Closed
ChoppinBlockParty opened this issue Oct 5, 2018 · 9 comments

Comments

@ChoppinBlockParty
Copy link

commented Oct 5, 2018

I have recently got confused by actions. Could you, please, clarify what is the right way to use it? I had chosen deleted a file in actions using ivy-dispatching-done, then I decide to ivy-resume, because I actually needed to open a file, of course, I had forgotten that my last action is delete and I hit ivy-done (e.g. `Enter). My file is gone, I had not stashed this file to git and, for some reasons I do not have backups of it (that is another issue to investigate). Could you suggest anything to avoid this problem in future?

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Oct 8, 2018

ivy-dispatching-done is a combination of ivy-read-action and ivy-done. The first command, also bound to C-M-a permanently modifies the action for the current session so that you can use it with e.g. C-M-m.

ivy-resume restores the last active completion session. It doesn't try to reset to the default action or anything like that.

One suggestion to avoid it would be to remove counsel-find-file-delete from the list of actions. I was hesitant to add it by default in the first place (I prefer to delete files only via dired's mark-and-confirm approach), but it seems many users actually want it there.

I don't think it's useful for ivy-resume to reset the action to default. Please close the issue if you agree. Otherwise let's keep it open for some more people to chime in.

@ChoppinBlockParty

This comment has been minimized.

Copy link
Author

commented Oct 8, 2018

Hmm, I see, good advice. Is it only counsel-find-file-delete which deletes the files, or there are others? I think I was using counsel-projetile-switch-project, does it use the same action? Can you suggest how to make an action that opens dired on the current file?

@iquiw

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2018

To avoid accidental file deletion, I think the followings may be useful.

  • Display the current action somewhere around the prompt.
  • Confirm to user before deleting file.
@ChoppinBlockParty

This comment has been minimized.

Copy link
Author

commented Oct 9, 2018

@iquiw Yup, do you have anything like this drafted?

Also I think

  • kill buffer/delete file action should be separated into two actions: kill buffer and delete file.

@abo-abo abo-abo closed this in cc8a58c Oct 9, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Oct 9, 2018

M-o k will now ask for confirmation unless delete-by-moving-to-trash is set.

I realize that this becomes a bit clunky when deleting multiple files within one session.

This can be improved in the future once ivy gets some kind of mark-candidate/bulk-action interface.

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Oct 9, 2018

Please let me know if your concern has been sufficiently addressed. And thanks for bringing this up.

@ChoppinBlockParty

This comment has been minimized.

Copy link
Author

commented Oct 10, 2018

Yes, I think it fixes main concerns. I have one question: if the file also has a buffer(s), will it ask to kill the buffers or not?

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Oct 10, 2018

if the file also has a buffer(s), will it ask to kill the buffers or not?

No, it will not ask. Dired only asks to kill the buffers visiting deleted files/directories when the function dired-clean-up-after-deletion is called and the dired-x library has been loaded by the user. Do you think Counsel should do this? I have no strong opinion either way.

@ChoppinBlockParty

This comment has been minimized.

Copy link
Author

commented Oct 10, 2018

Yes, I think, this is helpful.

basil-conto added a commit to basil-conto/swiper that referenced this issue Oct 10, 2018
counsel.el: Clean up buffers of deleted files
(counsel-find-file-delete):
Maybe delete buffers visiting recently deleted file.

Re: abo-abo#1774
abo-abo added a commit that referenced this issue Oct 26, 2018
counsel.el: Clean up buffers of deleted files
(counsel-find-file-delete):
Maybe delete buffers visiting recently deleted file.

Re: #1774
Fixes #1779
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.