From bf6e5daa086d4dbde812e95b00dd951f09f7d398 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 30 Sep 2017 21:39:57 +0800 Subject: [PATCH] Use stricter regex syntax boost regex tolerates non-escaped special characters, and escaped non-special characters. Standardize on stricter syntax, where special characters must be escaped, and non-special characters must not. --- rc/base/etc.kak | 4 ++-- rc/base/haskell.kak | 2 +- rc/base/ini.kak | 2 +- rc/base/javascript.kak | 2 +- rc/base/lua.kak | 8 ++++---- rc/base/ruby.kak | 2 +- rc/core/kakrc.kak | 6 +++--- rc/extra/coffee.kak | 2 +- rc/extra/kickstart.kak | 2 +- rc/extra/latex.kak | 2 +- rc/extra/pug.kak | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rc/base/etc.kak b/rc/base/etc.kak index 3efe55875..33acb111d 100644 --- a/rc/base/etc.kak +++ b/rc/base/etc.kak @@ -23,7 +23,7 @@ hook -group etc-resolv-conf-highlight global WinSetOption filetype=(?!etc-resolv ## /etc/hosts add-highlighter -group / group etc-hosts add-highlighter -group /etc-hosts regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute -add-highlighter -group /etc-hosts regex \#.*?$ 0:comment +add-highlighter -group /etc-hosts regex '#.*?$' 0:comment hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ add-highlighter ref etc-hosts } hook -group etc-hosts-highlight global WinSetOption filetype=(?!etc-hosts).* %{ remove-highlighter etc-hosts } @@ -31,7 +31,7 @@ hook -group etc-hosts-highlight global WinSetOption filetype=(?!etc-hosts).* %{ ## /etc/fstab add-highlighter -group / group etc-fstab add-highlighter -group /etc-fstab regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute -add-highlighter -group /etc-fstab regex \#.*?$ 0:comment +add-highlighter -group /etc-fstab regex '#.*?$' 0:comment hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ add-highlighter ref etc-fstab } hook -group etc-fstab-highlight global WinSetOption filetype=(?!etc-fstab).* %{ remove-highlighter etc-fstab } diff --git a/rc/base/haskell.kak b/rc/base/haskell.kak index f3a7abefb..6fd781c80 100644 --- a/rc/base/haskell.kak +++ b/rc/base/haskell.kak @@ -14,7 +14,7 @@ hook global BufCreate .*[.](hs) %{ add-highlighter -group / regions -default code haskell \ string '(??@\\\^|~=]) $ '' diff --git a/rc/base/ini.kak b/rc/base/ini.kak index 470c0b9d8..de28022c5 100644 --- a/rc/base/ini.kak +++ b/rc/base/ini.kak @@ -3,7 +3,7 @@ hook global BufCreate .*\.(repo|service|target|socket|ini|cfg) %{ } add-highlighter -group / regions -default code ini \ - comment (^|\h)\K[\#\;] $ '' + comment '(^|\h)\K[#;]' $ '' add-highlighter -group /ini/code regex "^\h*\[[^\]]*\]" 0:title add-highlighter -group /ini/code regex "^\h*([^\[][^=\n]*=)([^\n]*)" 1:variable 2:value diff --git a/rc/base/javascript.kak b/rc/base/javascript.kak index d14dd2634..2bcffb4f5 100644 --- a/rc/base/javascript.kak +++ b/rc/base/javascript.kak @@ -25,7 +25,7 @@ add-highlighter -group /javascript/single_string fill string add-highlighter -group /javascript/regex fill meta add-highlighter -group /javascript/comment fill comment add-highlighter -group /javascript/literal fill string -add-highlighter -group /javascript/literal regex \${.*?} 0:value +add-highlighter -group /javascript/literal regex \$\{.*?\} 0:value add-highlighter -group /javascript/code regex \$\w* 0:variable add-highlighter -group /javascript/code regex \b(document|false|null|parent|self|this|true|undefined|window)\b 0:value diff --git a/rc/base/lua.kak b/rc/base/lua.kak index f37e70394..9b453dbf3 100644 --- a/rc/base/lua.kak +++ b/rc/base/lua.kak @@ -12,10 +12,10 @@ hook global BufCreate .*[.](lua) %{ # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code lua \ - string '"' (? s ^ \h * \K \# \h * y gh j P } + try %{ exec -draft k s '^\h*\K#\h*' y gh j P } # wisely add end structure eval -save-regs x %{ try %{ exec -draft k s ^ \h + \" x y } catch %{ reg x '' } diff --git a/rc/core/kakrc.kak b/rc/core/kakrc.kak index 13875bdb7..1fa8852f0 100644 --- a/rc/core/kakrc.kak +++ b/rc/core/kakrc.kak @@ -12,17 +12,17 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code kakrc \ - comment (^|\h)\K\# $ '' \ + comment (^|\h)\K# $ '' \ double_string %{(^|\h)\K"} %{(?' '\<' \ + shell '(^|\h)\K%sh<' '>' '<' \ shell '(^|\h)\K-shell-(completion|candidates)\h+%\{' '\}' '\{' \ shell '(^|\h)\K-shell-(completion|candidates)\h+%\(' '\)' '\(' \ shell '(^|\h)\K-shell-(completion|candidates)\h+%\[' '\]' '\[' \ - shell '(^|\h)\K-shell-(completion|candidates)\h+%\<' '\>' '\<' + shell '(^|\h)\K-shell-(completion|candidates)\h+%<' '>' '<' %sh{ # Grammar diff --git a/rc/extra/coffee.kak b/rc/extra/coffee.kak index 081a63723..696544402 100644 --- a/rc/extra/coffee.kak +++ b/rc/extra/coffee.kak @@ -56,7 +56,7 @@ def -hidden coffee-filter-around-selections %{ def -hidden coffee-indent-on-new-line %{ eval -draft -itersel %{ # copy '#' comment prefix and following white spaces - try %{ exec -draft k s ^ \h * \K \# \h * y gh j P } + try %{ exec -draft k s '^\h*\K#\h*' y gh j P } # preserve previous line indent try %{ exec -draft \; K } # filter previous line diff --git a/rc/extra/kickstart.kak b/rc/extra/kickstart.kak index 7c47c9ca5..152a0ab6f 100644 --- a/rc/extra/kickstart.kak +++ b/rc/extra/kickstart.kak @@ -3,7 +3,7 @@ hook global BufCreate .*\.ks %{ } add-highlighter -group / regions -default code kickstart \ - comment (^|\h)\K\# $ '' \ + comment '(^|\h)\K#' $ '' \ double_string '"' (?