1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 01:24:52 +03:00

Slight cleanup in modeline.kak

This commit is contained in:
Maxime Coste 2016-02-10 21:26:56 +00:00
parent 8b7025b8ea
commit 050484ebe0

View File

@ -1,5 +1,5 @@
##
## modeline.kak by lenormf
## modeline.kak bylno|\'<ret> %opt{modeline}k %opt{modeline}X
##
## Currently supported modeline format: vim
@ -7,7 +7,8 @@
## Only a few options are supported, in order to prevent the
## buffers from poking around the configuration too much
# Amount of lines that will be checked at the beginning and the end of the buffer
# Amount of additional lines that will be checked at the beginning
# and the end of the buffer
decl int modelines 5
def -hidden _modeline-parse %{
@ -107,11 +108,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 modeline-parse %{
try %{
exec -draft "\%
s(\`(^[^\n]*\n?){%opt{modelines}})|((^[^\n]*\n?){%opt{modelines}}\')<ret>
s^[^\s]+?\s(vim?|kak(oune)?):\s?[^\n]+<ret>
<a-s>
:eval -draft -itersel _modeline-parse<ret>"
}
try %{ eval -draft %{
exec \%s\`|.\'<ret> %opt{modelines}k <a-x> %opt{modelines}X \
s^[^\s]+?\s(vim?|kak(oune)?):\s?[^\n]+<ret>
eval -draft -itersel _modeline-parse
} }
}