diff --git a/rc/modeline.kak b/rc/modeline.kak index baecea73..cb93b337 100644 --- a/rc/modeline.kak +++ b/rc/modeline.kak @@ -7,8 +7,6 @@ ## Only a few options are supported, in order to prevent the ## buffers from poking around the configuration too much -# Set to 'true' to parse modelines in buffers -decl bool modeline "true" # Amount of lines that will be checked at the beginning and the end of the buffer decl int modelines 5 @@ -106,8 +104,9 @@ def -hidden _modeline-parse %{ } } +# Add the following function to a hook on BufOpen to automatically parse modelines # Select the first and last `modelines` lines in the buffer, only keep modelines -def -hidden _modeline-crunch %{ +def modeline-parse %{ try %{ exec -draft "\% s(\`(^[^\n]*\n?){%opt{modelines}})|((^[^\n]*\n?){%opt{modelines}}\') @@ -116,11 +115,3 @@ s^[^\s]+?\s(vim?|kak(oune)?):\s?[^\n]+ :eval -draft -itersel _modeline-parse" } } - -hook global BufOpen .* %{ - %sh{ - if [ "${kak_opt_modeline}" = true ]; then - echo "eval _modeline-crunch" - fi - } -}