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
Tweak counsel-find-file-delete #1779
Conversation
Add trailing space to y-or-n-p prompt as per the function's docstring.
(counsel-find-file-delete): Don't prompt for directory deletion, which dired-delete-file already handles in a customizable way.
(counsel--yes-or-no-p): New function. (counsel-find-file-delete): Use it instead of hard-coding short y-or-n-p prompt for destructive operations like file deletions.
(counsel-find-file-delete): Maybe delete buffers visiting recently deleted file. Re: abo-abo#1774
I ran into the following
This is due to the implementation of One option is to hot-swap it with diff --git a/counsel.el b/counsel.el
index bfa63ac..2fd7089 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1742,7 +1742,8 @@ counsel-find-file-delete
;; `dired-delete-file', which see, already prompts for directories
(eq t (car (file-attributes x)))
(counsel--yes-or-no-p "Delete %s? " x))
- (dired-delete-file x dired-recursive-deletes delete-by-moving-to-trash)
+ (cl-letf (((symbol-function 'dired-make-relative) #'file-relative-name))
+ (dired-delete-file x dired-recursive-deletes delete-by-moving-to-trash))
(dired-clean-up-after-deletion x)
(ivy--reset-state ivy-last))) So long as you don't mind Another option is to pass the diff --git a/counsel.el b/counsel.el
index bfa63ac..9c55f8a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1742,7 +1742,9 @@ counsel-find-file-delete
;; `dired-delete-file', which see, already prompts for directories
(eq t (car (file-attributes x)))
(counsel--yes-or-no-p "Delete %s? " x))
- (dired-delete-file x dired-recursive-deletes delete-by-moving-to-trash)
+ (dired-delete-file (directory-file-name x)
+ dired-recursive-deletes
+ delete-by-moving-to-trash)
(dired-clean-up-after-deletion x)
(ivy--reset-state ivy-last))) So long as you don't mind the missing trailing slash of directory names. Yet another option is to leave things as they are, and hope the empty file name will make the user think twice about deleting the directory containing the file being visited by the current buffer. Thoughts, @abo-abo, @ChoppinBlockParty, @DamienCassou? |
Good catch. I am wondering will |
No, |
Yes, sure, sorry for that dumb question. Thant looks like weird behavior, may be dired functions do not fit for ivy? Because I do not think that I can reproduce this with dired. May be we should use default functions like |
Yes, but don't forget that it's an unlikely edge-case, not the usual behaviour, and that there are workarounds, as I mentioned earlier.
@DamienCassou argued in #1671 that
Feel free to implement this if you're interested. But I don't think it's possible to do so as flexibly as
Yes, this is universally true in Emacs. |
I actually do not understand the value what it is doing, except calling |
@basil-conto I do not want to be disturbing, it was just an opinion, please, feel free to merge your work, I find it very helpful and looking forward to try it out. |
@ChoppinBlockParty No, I think there's truth to what you're saying, I just haven't had the time to look at this issue again; sorry for the delay. |
Thanks, all. |
Please review each commit in turn.
Re: #1774
Cc: @ChoppinBlockParty