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
Closed

How to know what is the default action #1774

ChoppinBlockParty opened this issue Oct 5, 2018 · 9 comments

Comments

@ChoppinBlockParty
Copy link

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
Copy link
Owner

abo-abo 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
Copy link
Author

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
Copy link
Contributor

iquiw 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
Copy link
Author

ChoppinBlockParty 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 as completed in cc8a58c Oct 9, 2018
@abo-abo
Copy link
Owner

abo-abo 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
Copy link
Owner

abo-abo commented Oct 9, 2018

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

@ChoppinBlockParty
Copy link
Author

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

basil-conto 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
Copy link
Author

Yes, I think, this is helpful.

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

Re: abo-abo#1774
abo-abo pushed a commit that referenced this issue Oct 26, 2018
(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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants