From 9ecfcfad43a5958c5153204c2fe28aa6b445e7df Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 7 Dec 2013 13:56:56 +0000 Subject: [PATCH] use -try-client in kak files rather than ad-hoc shell logic --- src/rc/grep.kak | 12 +++++------- src/rc/make.kak | 12 +++++------- src/rc/man.kak | 16 +++++++--------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/rc/grep.kak b/src/rc/grep.kak index b98708b0..ecebdfd7 100644 --- a/src/rc/grep.kak +++ b/src/rc/grep.kak @@ -11,13 +11,11 @@ def -shell-params -file-completion \ ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' >& ${output} ) >& /dev/null < /dev/null & fi - [[ -n "$kak_opt_toolsclient" ]] && echo "eval -client '$kak_opt_toolsclient' %{" - - echo "edit! -fifo ${output} *grep* - set buffer filetype grep - hook buffer BufClose .* %{ nop %sh{ rm -r $(dirname ${output}) } }" - - [[ -n "$kak_opt_toolsclient" ]] && echo "}" + echo "eval -try-client '$kak_opt_toolsclient' %{ + edit! -fifo ${output} *grep* + set buffer filetype grep + hook buffer BufClose .* %{ nop %sh{ rm -r $(dirname ${output}) } } + }" }} hook global WinSetOption filetype=grep %{ diff --git a/src/rc/make.kak b/src/rc/make.kak index cd2fd220..37d299a4 100644 --- a/src/rc/make.kak +++ b/src/rc/make.kak @@ -6,13 +6,11 @@ def -shell-params make %{ %sh{ mkfifo ${output} ( eval ${kak_opt_makecmd} $@ >& ${output} ) >& /dev/null < /dev/null & - [[ -n "$kak_opt_toolsclient" ]] && echo "eval -client '$kak_opt_toolsclient' %{" - - echo "edit! -fifo ${output} *make* - set buffer filetype make - hook buffer BufClose .* %{ nop %sh{ rm -r $(dirname ${output}) } }" - - [[ -n "$kak_opt_toolsclient" ]] && echo "}" + echo "eval -try-client '$kak_opt_toolsclient' %{ + edit! -fifo ${output} *make* + set buffer filetype make + hook buffer BufClose .* %{ nop %sh{ rm -r $(dirname ${output}) } } + }" }} defhl make diff --git a/src/rc/man.kak b/src/rc/man.kak index 386f2df0..8d61a4f1 100644 --- a/src/rc/man.kak +++ b/src/rc/man.kak @@ -14,14 +14,7 @@ hook global WinSetOption filetype=(?!man).* %{ rmhooks window man-hooks } -def -shell-params man %{ %sh{ - [[ -z "$@" ]] && set -- "$kak_selection" - # eval in the docsclient context so that kak_window_width is the good one - if [[ -n "$kak_opt_docsclient" && "$kak_client" != "$kak_opt_docsclient" ]]; then - echo "eval -client $kak_opt_docsclient %{ man $@ }" - exit - fi - +def -hidden -shell-params _man %{ %sh{ tmpfile=$(mktemp /tmp/kak-man-XXXXXX) MANWIDTH=${kak_window_width} man "$@" | col -b > ${tmpfile} if (( ${PIPESTATUS[0]} == 0 )); then @@ -33,4 +26,9 @@ def -shell-params man %{ %sh{ echo "echo %{man '$@' failed: see *debug* buffer for details }" rm ${tmpfile} fi -}} +} } + +def -shell-params man %{ %sh{ + [[ -z "$@" ]] && set -- "$kak_selection" + echo "eval -try-client %opt{docsclient} _man $@" +} }