diff --git a/.config/kak/autoload/expand.kak b/.config/kak/autoload/expand.kak index 9435beee..1bc54ec9 100644 --- a/.config/kak/autoload/expand.kak +++ b/.config/kak/autoload/expand.kak @@ -1,5 +1,6 @@ provide-module expand %— - define-command expand-impl %{ + define-command -hidden -params 1 expand-impl %{ + # param expand or shrink evaluate-commands -itersel %sh{ sel="$kak_selection_desc" left=${sel%%,*} @@ -8,16 +9,29 @@ provide-module expand %— right_d=${right#*.} if [ "$left_d" -gt "$right_d" ]; then # sel facing back - echo 'execute-keys HL' + if [ "$1" = 'expand' ]; then + echo 'execute-keys "HL"' + else + echo 'execute-keys "LH"' + fi elif [ "$left_d" -lt "$right_d" ]; then # sel facing forward - echo 'execute-keys LH' + if [ "$1" = 'expand' ]; then + echo 'execute-keys "LH"' + else + echo 'execute-keys "HL"' + fi else echo 'nop' #single cursor do nothing fi } } - define-command shrink %{ - execute-keys 'HL' + define-command expand-selections %{ + expand-impl expand } + define-command shrink-selections %{ + expand-impl shrink + } + map global object ': expand-selections' + map global object ': shrink-selections' —