diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2020-09-16 12:10:05 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2020-09-18 14:54:57 +0300 |
| commit | 2d78b0760d2d755321dbc3321cb2e47d5d08c90f (patch) | |
| tree | 35bb727f558f022f93122d1c8d67747213166879 /rc/detection | |
| parent | 30ee97386d2bd8d0240803c8a0fb2f57285a9d4c (diff) | |
rc modeline: Error out on unsupported formats
This commit makes `:modeline-parse` grab all lines that look like
modelines, and lets the parser deal with invalid formats.
This allows actually printing an error on unsupported modelines
formats, instead of ignoring them upfront.
Diffstat (limited to 'rc/detection')
| -rw-r--r-- | rc/detection/modeline.kak | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index 516080db..dc092a1c 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -65,7 +65,7 @@ define-command -hidden modeline-parse-impl %{ case "${kak_selection}" in *vi:*|*vim:*) type_selection="vim";; *kak:*|*kakoune:*) type_selection="kakoune";; - *) printf 'echo -debug Unsupported modeline format' \ + *) printf 'echo -debug %s' "$(kakquote "Unsupported modeline format: ${kak_selection}")" \ | kak -p "${kak_session}"; exit 1 ;; esac @@ -109,7 +109,7 @@ define-command -hidden modeline-parse-impl %{ define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ try %{ evaluate-commands -draft %{ execute-keys <percent> "s(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z<ret>" \ - s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x> + s^\S*?\s+?\w+:\s?[^\n]+<ret> <a-x> evaluate-commands -draft -itersel modeline-parse-impl } } } |
