From e847c9effa5bb2c3215e6fe8f81881fcce7754c8 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Sat, 30 Mar 2019 17:16:52 +0300 Subject: [PATCH] add first match to grep buffer --- rc/modules/sk-grep.kak | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rc/modules/sk-grep.kak b/rc/modules/sk-grep.kak index 8285a41..477318e 100644 --- a/rc/modules/sk-grep.kak +++ b/rc/modules/sk-grep.kak @@ -43,14 +43,17 @@ define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{ printf "%s\n" "fzf -kak-cmd %{fzf-sk-grep-handler} -fzf-impl %{sk -m -i -c '$kak_opt_fzf_sk_grep_command {}'} -fzf-args %{--expect ctrl-w $additional_flags} -multiple-cmd %{fzf-sk-populate-grep} -post-action %{buffer %opt{fzf_sk_first_file}}" }} -define-command -hidden fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{ - printf "%s\n" "$1" | awk '{ - file = $0; sub(/:.*/, "", file); gsub("&", "&&", file); - line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line) - print "edit -existing %&" file "&; execute-keys %&" line "gxvc&" - print "set-option global fzf_sk_first_file %&" file "&" - }' -}} +define-command -hidden fzf-sk-grep-handler -params 1 %{ + evaluate-commands %sh{ + printf "%s\n" "$1" | awk '{ + file = $0; sub(/:.*/, "", file); gsub("&", "&&", file); + line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line) + print "edit -existing %&" file "&; execute-keys %&" line "gxvc&" + print "set-option global fzf_sk_first_file %&" file "&" + }' + } + fzf-sk-populate-grep %arg{1} +} define-command -hidden fzf-sk-populate-grep -params 1 %{ try %{