1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 23:34:12 +03:00

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'"
fi
}
evaluate-commands -draft -no-hooks -save-regs '|' %{
evaluate-commands -draft -no-hooks -save-regs 'e|' %{
set-register e nop
set-register '|' %{
format_in="$(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
cat "$format_out"
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"
fi
rm -f "$format_in" "$format_out"
}
execute-keys '|<ret>'
%reg{e}
}
}