andreyorst / fzf.kak

FZF for Kakoune
MIT License
143 stars 33 forks source link

[Feature Request] delete buffer #57

Closed losnappas closed 5 years ago

losnappas commented 5 years ago

How about a delete buffer hotkey into the buffer menu?

andreyorst commented 5 years ago

there was this feature at some point, but I've removed it because it was making implementation complex. Although, Idid a refactoring so maybe I could bring it back. I'll see if I can do it

andreyorst commented 5 years ago

I'm not sure that this is possible with current implementation without duplication of fzf comand source code into fzf-buffer command for single feature. The problem is that keypresses are handled in this case statement:

case ${line} in
    ${kak_opt_fzf_window_map})     wincmd="fzf-window"     ;;
    ${kak_opt_fzf_vertical_map})   wincmd="fzf-vertical"   ;;
    ${kak_opt_fzf_horizontal_map}) wincmd="fzf-horizontal" ;;
    *)                             item=${line} ;;
esac

In order to make it work for deleting buffers I need to add new arm here like this:

case ${line} in
    ${kak_opt_fzf_window_map})     wincmd="fzf-window"     ;;
    ${kak_opt_fzf_vertical_map})   wincmd="fzf-vertical"   ;;
    ${kak_opt_fzf_horizontal_map}) wincmd="fzf-horizontal" ;;
    ${kak_opt_fzf_bufdelete_map})  "action that deletes the buffer here and restarts fzf-buffer" ;;
    *)                             item=${line} ;;
esac

But this means that all other commands will attempt to delete buffer if this key is pressed, which is not good. I could wrap it with ifs but it will make fzf command non generic.

I'll think about it for some more.

losnappas commented 5 years ago

Right, I see the problem. One option could be to make a new "extra" keybind that would run a user-specified command, so it would be at least a bit more generic. Then I could run fzf-buffers "db | fzf-buffer", for example, but idk if that would see any real use besides this. ~And speaking of that example command, I'd have to do the run (){ ... } run trick like with linters.~ nvm I'd just make a normal define-command, because this isn't shell side, I suppose.

andreyorst commented 5 years ago

I've just pushed new command with the fzf-buffer.kak module: fzf-delete-buffer mapped to <a-b> in fzf-mode. See if it works for you