rc modeline: Print error messages correctly

This commit is contained in:
Frank LENORMAND 2020-09-16 11:58:47 +03:00
parent d02cb43a88
commit 7731fe4cb2

View File

@ -30,14 +30,16 @@ define-command -hidden modeline-parse-impl %{
case "${value}" in case "${value}" in
unix) tr="eolformat lf";; unix) tr="eolformat lf";;
dos) tr="eolformat crlf";; dos) tr="eolformat crlf";;
*) printf %s\\n "echo -debug 'Unsupported file format: ${value}'";; *) printf 'echo -debug %s' "$(kakquote "Unsupported file format: ${value}")" \
| kak -p "${kak_session}";;
esac esac
;; ;;
ft|filetype) tr=$(kakquote filetype "{value}");; ft|filetype) tr=$(kakquote filetype "{value}");;
bomb) tr="BOM utf8";; bomb) tr="BOM utf8";;
nobomb) tr="BOM none";; nobomb) tr="BOM none";;
spelllang|spl) tr=$(kakquote spell_lang "{value%%,*}");; spelllang|spl) tr=$(kakquote spell_lang "{value%%,*}");;
*) printf %s\\n "echo -debug 'Unsupported vim variable: ${key}'";; *) printf 'echo -debug %s' "$(kakquote "Unsupported vim variable: ${key}")" \
| kak -p "${kak_session}";;
esac esac
[ -n "${tr}" ] && printf %s\\n "set-option buffer ${tr}" [ -n "${tr}" ] && printf %s\\n "set-option buffer ${tr}"
@ -50,7 +52,8 @@ define-command -hidden modeline-parse-impl %{
case "${key}" in case "${key}" in
scrolloff|tabstop|indentwidth|autowrap_column|eolformat|filetype|BOM|spell_lang);; scrolloff|tabstop|indentwidth|autowrap_column|eolformat|filetype|BOM|spell_lang);;
*) printf %s\\n "echo -debug 'Unsupported kakoune variable: ${key}'" *) printf 'echo -debug %s' "$(kakquote "Unsupported kakoune variable: ${key}")" \
| kak -p "${kak_session}"
return;; return;;
esac esac
@ -60,7 +63,8 @@ define-command -hidden modeline-parse-impl %{
case "${kak_selection}" in case "${kak_selection}" in
*vi:*|*vim:*) type_selection="vim";; *vi:*|*vim:*) type_selection="vim";;
*kak:*|*kakoune:*) type_selection="kakoune";; *kak:*|*kakoune:*) type_selection="kakoune";;
*) echo "echo -debug Unsupported modeline format"; exit 1 ;; *) printf 'echo -debug Unsupported modeline format' \
| kak -p "${kak_session}"; exit 1 ;;
esac esac
# The following subshell will keep the actual options of the modeline, and strip: # The following subshell will keep the actual options of the modeline, and strip: