From 19e36425f4887156d5370ce5d7e03b75f5471e5d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 5 Aug 2016 09:05:47 +0100 Subject: [PATCH] c-indent: Restore previous indent after a closing parenthesis --- rc/core/c-family.kak | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 1ac3dddc..b9765d86 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -42,8 +42,13 @@ def -hidden _c-family-trim-autoindent %[ eval -draft -itersel %[ def -hidden _c-family-indent-on-newline %[ eval -draft -itersel %[ exec \; - ## indent new lines with the same level as the previous one - exec -draft K + try %[ + ## if previous line closed a paren, copy indent of the opening paren line + exec -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?$ mJ s\`|.\' 1 + ] catch %[ + ## else indent new lines with the same level as the previous one + exec -draft K + ] ## remove previous empty lines resulting from the automatic indent try %[ exec -draft k H ^\h+$ d ] ## indent after an opening brace