cp-find-file: Add delete action
Make counsel-projectile kill action delete files Update README
This commit is contained in:
parent
511f78dd17
commit
18758602e8
2 changed files with 13 additions and 6 deletions
|
|
@ -97,7 +97,7 @@ This command lets you quickly jump to a project buffer or file. It uses ivy to d
|
|||
| :----------- | :--------------------------------------------------------------------------------- |
|
||||
| <kbd>o</kbd> | Open buffer or file in current window (default action) |
|
||||
| <kbd>j</kbd> | Open buffer or file in other window |
|
||||
| <kbd>k</kbd> | Kill buffer (does nothing for files) |
|
||||
| <kbd>k</kbd> | Kill buffer or delete file |
|
||||
| <kbd>x</kbd> | Open file externally (does nothing for buffers) |
|
||||
| <kbd>r</kbd> | Open file as root (does nothing for buffers) |
|
||||
| <kbd>m</kbd> | Find file manually: call `counsel-find-file` from buffer or file's directory |
|
||||
|
|
@ -146,6 +146,7 @@ This command is a replacement for `projectile-find-file`. It displays a list of
|
|||
| <kbd>x</kbd> | Open file externally |
|
||||
| <kbd>r</kbd> | Open file as root |
|
||||
| <kbd>m</kbd> | Find file manually: call `counsel-find-file` from file's directory |
|
||||
| <kbd>k</kbd> | Delete file |
|
||||
| <kbd>p</kbd> | Switch project: call `counsel-projectile-switch-project` (see above) |
|
||||
## The `counsel-projectile-find-file-dwim` command
|
||||
Default key binding: <kbd>C-c p g</kbd>.
|
||||
|
|
|
|||
|
|
@ -296,6 +296,8 @@ It is also possible to use a custom matcher. It must be a function taking two a
|
|||
"open as root")
|
||||
("m" counsel-projectile-find-file-action-find-file-manually
|
||||
"find file manually")
|
||||
("k" counsel-projectile-find-file-action-delete
|
||||
"delete")
|
||||
("p" (lambda (_) (counsel-projectile-switch-project))
|
||||
"switch project"))
|
||||
'counsel-projectile)
|
||||
|
|
@ -362,6 +364,10 @@ on `counsel-find-file-ignore-regexp'."
|
|||
(counsel-find-file-as-root (projectile-expand-root file))
|
||||
(run-hooks 'projectile-find-file-hook))
|
||||
|
||||
(defun counsel-projectile-find-file-action-delete (file)
|
||||
"Delete FILE."
|
||||
(counsel-find-file-delete (projectile-expand-root file)))
|
||||
|
||||
(defun counsel-projectile-find-file-transformer (str)
|
||||
"Transform non-visited file names with `ivy-virtual' face."
|
||||
(if (not (get-file-buffer (projectile-expand-root str)))
|
||||
|
|
@ -1254,8 +1260,8 @@ action."
|
|||
"current window")
|
||||
("j" counsel-projectile-action-other-window
|
||||
"other window")
|
||||
("k" counsel-projectile-action-kill-buffer
|
||||
"kill buffer")
|
||||
("k" counsel-projectile-action-kill-delete
|
||||
"kill buffer / delete-file")
|
||||
("x" counsel-projectile-action-file-extern
|
||||
"open file externally")
|
||||
("r" counsel-projectile-action-file-root
|
||||
|
|
@ -1339,11 +1345,11 @@ files."
|
|||
(switch-to-buffer-other-window name)
|
||||
(counsel-projectile-find-file-action-other-window name)))
|
||||
|
||||
(defun counsel-projectile-action-kill-buffer (name)
|
||||
"Kill buffer named NAME."
|
||||
(defun counsel-projectile-action-kill-delete (name)
|
||||
"Kill buffer or delete-file named NAME."
|
||||
(if (member name counsel-projectile--buffers)
|
||||
(ivy--kill-buffer-action name)
|
||||
(message "This action only applies to buffers.")))
|
||||
(counsel-projectile-find-file-action-delete name)))
|
||||
|
||||
(defun counsel-projectile-action-find-file-manually (name)
|
||||
"Call `counsel-find-file' from default directory of buffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue