From ee65954ed4035c2ca55ab5b936ff5a183e5b2db3 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 31 Oct 2018 16:05:26 -0700 Subject: [PATCH 1/2] Make statement after if/else/while/for optional for indenting c-family --- rc/core/c-family.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 71eb94a9..bcb4b9b4 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -47,9 +47,9 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i # indent after a label try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace - try %< execute-keys -draft k \b(if|else|for|while)\h*\(.+?\)\h*$ j > + try %< execute-keys -draft k \b(if|else|for|while)\h*(\(.+?\)\h*)?$ j > # deindent after a single line statement end - try %< execute-keys -draft K \;\h*$ K s\b(if|else|for|while)\h*\(.*\)\h*$|.\z 1 > + try %< execute-keys -draft K \;\h*$ K s\b(if|else|for|while)\h*(\(.+?\)\h*)?$|.\z 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %< From 521e5032c94774ac9b72f1f42d8c802f22165b5e Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Thu, 1 Nov 2018 00:21:48 -0700 Subject: [PATCH 2/2] Don't require content in parens for single statment indent --- rc/core/c-family.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index bcb4b9b4..55e08c6a 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -47,9 +47,9 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i # indent after a label try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace - try %< execute-keys -draft k \b(if|else|for|while)\h*(\(.+?\)\h*)?$ j > + try %< execute-keys -draft k \b(if|else|for|while)\h*(\(.*?\)\h*)?$ j > # deindent after a single line statement end - try %< execute-keys -draft K \;\h*$ K s\b(if|else|for|while)\h*(\(.+?\)\h*)?$|.\z 1 > + try %< execute-keys -draft K \;\h*$ K s\b(if|else|for|while)\h*(\(.*?\)\h*)?$|.\z 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %<