From 507ed69dda9d8c2787488cfb1348a2ccb861bddc Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Mon, 8 Feb 2016 11:30:37 +0200 Subject: [PATCH] Get rid of the `modeline` option to let users set hooks manually --- rc/modeline.kak | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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 - } -}