From 4c39743b69be5a6aa3df969042574ac31fe588f7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 30 Oct 2013 08:57:38 +0000 Subject: [PATCH] cpp.kak: replace filters with hooks --- src/rc/cpp.kak | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index 18d4e96a..8bcc987a 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -18,16 +18,15 @@ hook global WinSetOption filetype=cpp %~ addhl -group cpp-highlight regex "^\h*?#.*?(?s\h+$d } catch %{} } + hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks^\h+yjP } catch %{} ] # preserve previous line indent + hook window InsertKey \n -id cpp-hooks %[ try %[ exec -draft k[{(]\h*$j ] catch %{} ] # indent after lines ending with { or ( + hook window InsertKey \} -id cpp-hooks %[ try %[ exec -draft ^\h+\}$< ] catch %{} ] # deindent on insert } alone on a line + hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft ks\h+$d } catch %{} ] # cleanup trailing white space son previous line ~ hook global WinSetOption filetype=(?!cpp).* %{ rmhl cpp-highlight - rmfilter cpp-filters rmhooks window cpp-hooks }