-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Delete file or kill buffer DWIM [Feature request] #164
Comments
* ivy.el (ivy-switch-buffer-map): New defvar. Re #164
* counsel.el (counsel-find-file-map): New defvar. Re #164
You could add something like this to your config: (define-key
ivy-switch-buffer-map
(kbd "C-k")
(lambda ()
(interactive)
(ivy-set-action 'kill-buffer)
(ivy-done))) I'm currently working on multiple actions for a single command. Similar to
|
* counsel.el (counsel-find-file): Update. * ivy.el (ivy--buffer-list): Update. Re #164
While in "C-o": - Use "s" to make "C-m", "C-j", "C-M-n" and "C-M-p" kill - Use "w" to switch back to normal. Re #164
Works great with btw, why have the |
(defun counsel-find-file ()
"Forward to `find-file'."
(interactive)
(ivy-read "Find file: " 'read-file-name-internal
:matcher #'counsel--find-file-matcher
:action (cons
1
`(("default"
(lambda (x)
(find-file
(expand-file-name x ivy--directory))))
(,(propertize "delete"
'face 'font-lock-warning-face)
(lambda (x)
(delete-file
(expand-file-name x ivy--directory))))))
:preselect (when counsel-find-file-at-point
(require 'ffap)
(ffap-guesser))
:require-match 'confirm-after-completion
:history 'file-name-history
:keymap counsel-find-file-map)) |
Because most of
I tried remapping |
I'm afraid of deleting files by accident: by mashing sc you can delete a file by accident. But I don't want to make you redefine |
I am fine redefining that function. But adding that variable would also mean easy customizability of any function using I also feared of accidental deletion and so I gave |
* ivy.el (ivy--actions-list): New defvar. Store the exit points per command. (ivy-set-actions): New defun. Use this to set the extra exit points for each command. (ivy-read): Account for `ivy--actions-list'. (ivy-switch-buffer): Set extra action to kill the buffer. Update the call to `ivy-read'. * counsel.el (counsel-locate): Use the single action in the function and customize the rest via `ivy-set-actions'. Re #164
Added the new interface. Give it a try for your file-deleting application. |
Works great! Thank you. (ivy-set-actions
'counsel-find-file
`((,(propertize "delete" 'face 'font-lock-warning-face)
(lambda (x) (delete-file (expand-file-name x ivy--directory)))))) |
I have a question regarding the switch-buffer kill, What would I have to add to kill a buffer, keep the ivy minibuffer open, and update the ivy-minibuffer to get rid of the killed buffer? I'm also using ivy-rich, just in case you can't reproduce. |
@JohnLunzer I think you're looking for C-c C-k. |
You know... you just have the answer for everything don't you ;) That's great. With that command and Ivy-rich I feel like I can abandon Out of curiosity, so I don't ask stupid questions in the future, what is the prescribed method for showing ivy-x-map keybindings while in an ivy minibuffer? |
Usually, |
What about C-hb, AKA |
I have switched to using counsel and ivy instead of ido and this is one of the features I miss from ido:
C-x C-f
, if the selection is on a file name that is not open in one of the buffers,C-k
will delete (or trash, depending ondelete-by-moving-to-trash
) that file name.C-k
will kill the selected buffer if open. If the buffer is already closed (virtual buffer) and if that buffer was associated to a file name, that file will be deleted (or trashed).It will be nice to have these functionalities in
counsel-find-file
andivy-switch-buffer
.Currently, I need to switch to that file/buffer and then delete/kill it.
The text was updated successfully, but these errors were encountered: