BUG: modeline-parse not working (?)
sdothum opened this issue · comments
I have in my kakrc file
hook global BufOpenFile .* %{ modeline-parse }
"Some" shell scripts I have with
# kak: filetype=sh
do not have their filetype set. Manually running "modeline-parse" also does not set the filetype. Running
set buffer filetype sh
manually does set the filetype for these problem files.
Even if i remove the few community plugs from autoload and run kak without a kakrc file, the same results occur for the problem scripts.
Oddly, this is not pervasive. Most of my scripts have their filetype set properly -- i am uncertain whether this is simply file.kak determining the correct filetype. There are no modeline-parse errors in debug.
I have to think there is something particular to my setup since i can't imagine this problem has gone unnoticed. Running kakoune on Alpine 3.19 (latest stable).
does it happen with HOME=$(mktemp -d) kak
? Without a reproducer I can't feasibly help.
If the problem is really in modeline-parse
(seems unlikely) you can use this to debug:
diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak
index 7600a53ba..f4023c017 100644
--- a/rc/detection/modeline.kak
+++ b/rc/detection/modeline.kak
@@ -12,6 +12,7 @@ declare-option -docstring "amount of lines that will be checked at the beginning
define-command -hidden modeline-parse-impl %{
evaluate-commands %sh{
+ set -x
kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; }
# Translate a vim option into the corresponding kakoune one
also be aware that by default modeline-parse only looks at the top and bottom 5 lines
Thanks for the patch suggestion to yield more information. Found it! Pretty obscure..
modeline-parse was parsing out on nearby lines above (i have my modeline at the end of the file) keywords with a trailing colon ":" (which were neither vim: or kak:) and failing out.
Since i have my modelines at the EOF, i added
set global modelines 2
to my kakrc.
Shouldn't modeline.kak simply ignore anything but lines with kak: or vim: ?