I’m trying to adapt c-family.kak define-commands for the java.kak filetype and running into a closing braces problem.
# c-family.kak#L124
define-command -hidden c-family-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line
try %[
# in case open curly brace follows a closing paren, align indent with opening paren
execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm <a-F>)M <a-k> \A\(.*\)\h\{.*\}\z <ret> <a-S>1<a-&>
] catch %[
# otherwise align with open curly brace
execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm<a-S>1<a-&>
] catch %[]
]
here is where it is going right
# works correctly on parenthesis then closing brace
# execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm <a-F>)M <a-k> \A\(.*\)\h\{.*\}\z <ret> <a-S>1<a-&>
#
public static void main(String[] args) {
() {
}
}
# when brace starts on newline
#
public static void main(String[] args)
{
{
}
}
here is where it is going wrong
# produces incorrect indentation on closing brace
# execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hm<a-S>1<a-&>
#
public static void main(String[] args) {
{
}
}
this should do the align job correctly hm<a-S>1<a-&>
but doesn’t. What am I missing guys?