Merge remote-tracking branch 'krobelus/format-show-error-in-client'

This commit is contained in:
Maxime Coste 2022-04-11 19:52:15 +10:00
commit 5b7f112fdc

View File

@ -14,7 +14,8 @@ define-command format-selections -docstring "Format the selections individually"
echo "fail 'The option ''formatcmd'' must be set'" echo "fail 'The option ''formatcmd'' must be set'"
fi fi
} }
evaluate-commands -draft -no-hooks -save-regs '|' %{ evaluate-commands -draft -no-hooks -save-regs 'e|' %{
set-register e nop
set-register '|' %{ set-register '|' %{
format_in="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter.XXXXXX)" format_in="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter.XXXXXX)"
format_out="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter.XXXXXX)" format_out="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter.XXXXXX)"
@ -24,12 +25,13 @@ define-command format-selections -docstring "Format the selections individually"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
cat "$format_out" cat "$format_out"
else else
printf 'eval -client %s %%{ fail formatter returned an error %s }\n' "$kak_client" "$?" | kak -p "$kak_session" echo "set-register e fail formatter returned an error (exit code $?)" >"$kak_command_fifo"
cat "$format_in" cat "$format_in"
fi fi
rm -f "$format_in" "$format_out" rm -f "$format_in" "$format_out"
} }
execute-keys '|<ret>' execute-keys '|<ret>'
%reg{e}
} }
} }