From 2ab9f65b369a2078a87c9878553d7f5c075ec418 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 14 Nov 2017 13:32:46 +0800 Subject: [PATCH] c-family.kak: Use in various auto indent hooks --- rc/core/c-family.kak | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index aa5b4ca0..306837cd 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -32,7 +32,7 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i execute-keys \; try %< # if previous line closed a paren, copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?$ mJ s\A|.\z 1 + execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?$ mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K @@ -51,7 +51,7 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i # Go to opening parenthesis and opening brace, then select the most nested one try %< try %< execute-keys [bZ[B > catch %< execute-keys [B > > # Validate selection and get first and last char - execute-keys \A[{(](\h*\S+)+\n L s\A|.\z + execute-keys \A[{(](\h*\S+)+\n L # Remove eventual indent from new line try %< execute-keys -draft s\h+ d > # Now align that new line with the opening parenthesis/brace @@ -61,12 +61,12 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i define-command -hidden c-family-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren - try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] + try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z 1 ] ] define-command -hidden c-family-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line - try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] + try %[ execute-keys -itersel -draft ^\h+\}$hm1 ] ] define-command -hidden c-family-insert-on-closing-curly-brace %[