Get rid of the modeline option to let users set hooks manually

This commit is contained in:
Frank LENORMAND 2016-02-08 11:30:37 +02:00
parent 94674b63e0
commit 507ed69dda

View File

@ -7,8 +7,6 @@
## Only a few options are supported, in order to prevent the ## Only a few options are supported, in order to prevent the
## buffers from poking around the configuration too much ## 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 # Amount of lines that will be checked at the beginning and the end of the buffer
decl int modelines 5 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 # Select the first and last `modelines` lines in the buffer, only keep modelines
def -hidden _modeline-crunch %{ def modeline-parse %{
try %{ try %{
exec -draft "\% exec -draft "\%
s(\`(^[^\n]*\n?){%opt{modelines}})|((^[^\n]*\n?){%opt{modelines}}\')<ret> s(\`(^[^\n]*\n?){%opt{modelines}})|((^[^\n]*\n?){%opt{modelines}}\')<ret>
@ -116,11 +115,3 @@ s^[^\s]+?\s(vim?|kak(oune)?):\s?[^\n]+<ret>
:eval -draft -itersel _modeline-parse<ret>" :eval -draft -itersel _modeline-parse<ret>"
} }
} }
hook global BufOpen .* %{
%sh{
if [ "${kak_opt_modeline}" = true ]; then
echo "eval _modeline-crunch"
fi
}
}