From 21614cb06ea4f7a7349c628e5b8a754f730b2f0d Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Tue, 22 Oct 2019 11:02:06 +0200 Subject: [PATCH] src: Create a named key This commit allows using the expansion in commands, instead of `\;`. It makes commands look more elegant, and prevents new-comers from falling into the trap of using without escaping the semicolon. --- rc/filetype/awk.kak | 4 ++-- rc/filetype/c-family.kak | 10 +++++----- rc/filetype/cabal.kak | 2 +- rc/filetype/coffee.kak | 2 +- rc/filetype/css.kak | 2 +- rc/filetype/cucumber.kak | 2 +- rc/filetype/d.kak | 6 +++--- rc/filetype/dart.kak | 6 +++--- rc/filetype/elixir.kak | 4 ++-- rc/filetype/elm.kak | 6 +++--- rc/filetype/fish.kak | 8 ++++---- rc/filetype/gas.kak | 2 +- rc/filetype/go.kak | 6 +++--- rc/filetype/haml.kak | 2 +- rc/filetype/haskell.kak | 6 +++--- rc/filetype/hbs.kak | 2 +- rc/filetype/html.kak | 2 +- rc/filetype/i3.kak | 2 +- rc/filetype/java.kak | 6 +++--- rc/filetype/javascript.kak | 2 +- rc/filetype/json.kak | 2 +- rc/filetype/just.kak | 2 +- rc/filetype/kakrc.kak | 4 ++-- rc/filetype/ledger.kak | 4 ++-- rc/filetype/lua.kak | 4 ++-- rc/filetype/makefile.kak | 2 +- rc/filetype/markdown.kak | 2 +- rc/filetype/moon.kak | 8 ++++---- rc/filetype/nim.kak | 4 ++-- rc/filetype/nix.kak | 2 +- rc/filetype/perl.kak | 6 +++--- rc/filetype/php.kak | 2 +- rc/filetype/pony.kak | 2 +- rc/filetype/protobuf.kak | 4 ++-- rc/filetype/pug.kak | 2 +- rc/filetype/python.kak | 4 ++-- rc/filetype/r.kak | 10 +++++----- rc/filetype/ragel.kak | 2 +- rc/filetype/ruby.kak | 10 +++++----- rc/filetype/rust.kak | 2 +- rc/filetype/sass.kak | 2 +- rc/filetype/scala.kak | 2 +- rc/filetype/sh.kak | 2 +- rc/filetype/taskpaper.kak | 2 +- rc/filetype/toml.kak | 2 +- rc/filetype/yaml.kak | 2 +- src/keys.cc | 1 + 47 files changed, 87 insertions(+), 86 deletions(-) diff --git a/rc/filetype/awk.kak b/rc/filetype/awk.kak index af9d4492..663174b7 100644 --- a/rc/filetype/awk.kak +++ b/rc/filetype/awk.kak @@ -71,7 +71,7 @@ evaluate-commands %sh{ define-command -hidden awk-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent - try %[ execute-keys -draft \; K ] + try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line try %[ execute-keys -draft k s \h+$ d ] # indent after line ending in opening curly brace @@ -80,7 +80,7 @@ define-command -hidden awk-indent-on-new-line %[ ] define-command -hidden awk-trim-indent %{ - try %{ execute-keys -draft \; s ^\h+$ d } + try %{ execute-keys -draft s ^\h+$ d } } @ diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index dbf342a4..b064224e 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -68,14 +68,14 @@ define-command -hidden c-family-trim-indent %{ } define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -itersel %< - execute-keys \; + execute-keys try %< # if previous line is part of a comment, do nothing execute-keys -draft /\* ^\h*[^/*\h] > catch %< # else if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K @@ -88,7 +88,7 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i 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 s\)\h*(?://[^\n]+)?\n\z \ - mB \A\b(if|for|while)\b j > + mB \A\b(if|for|while)\b j > try %< execute-keys -draft k s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end @@ -104,7 +104,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 %< execute-keys [c [({],[)}] > # Validate selection and get first and last char - execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L + execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L # Remove possibly incorrect indent from new line which was copied from previous line try %< execute-keys -draft s\h+ d > # Now indent and align that new line with the opening parenthesis/brace @@ -136,7 +136,7 @@ define-command -hidden c-family-insert-on-closing-curly-brace %[ ] define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[ - execute-keys \; + execute-keys try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix diff --git a/rc/filetype/cabal.kak b/rc/filetype/cabal.kak index 6250350f..77519954 100644 --- a/rc/filetype/cabal.kak +++ b/rc/filetype/cabal.kak @@ -55,7 +55,7 @@ define-command -hidden cabal-indent-on-new-line %[ # copy '#' comment prefix and following white spaces try %[ execute-keys -draft k s ^\h*\K#\h* y gh j P ] # preserve previous line indent - try %[ execute-keys -draft \; K ] + try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : cabal-trim-indent ] # indent after lines ending with { or : diff --git a/rc/filetype/coffee.kak b/rc/filetype/coffee.kak index ecd80403..ecb3a1a7 100644 --- a/rc/filetype/coffee.kak +++ b/rc/filetype/coffee.kak @@ -75,7 +75,7 @@ define-command -hidden coffee-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s '^\h*\K#\h*' y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : coffee-trim-indent } # indent after start structure diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 451fa8af..8825c84e 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -66,7 +66,7 @@ define-command -hidden css-trim-indent %{ define-command -hidden css-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent - try %[ execute-keys -draft \; K ] + try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : css-trim-indent ] # indent after lines ending with with { diff --git a/rc/filetype/cucumber.kak b/rc/filetype/cucumber.kak index f8db989e..890985c7 100644 --- a/rc/filetype/cucumber.kak +++ b/rc/filetype/cucumber.kak @@ -85,7 +85,7 @@ define-command -hidden cucumber-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : cucumber-trim-indent } # indent after lines containing : diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak index 397109d3..9f70b7b3 100644 --- a/rc/filetype/d.kak +++ b/rc/filetype/d.kak @@ -108,7 +108,7 @@ add-highlighter shared/d/code/ regex "\bmodule\s+([\w_-]+)\b" 1:module define-command -hidden d-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line @@ -116,11 +116,11 @@ define-command -hidden d-indent-on-new-line %~ # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,} yP } + try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for - try %[ execute-keys -draft \;)MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] + try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] = ~ diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak index 6bb40fa3..541c1e58 100644 --- a/rc/filetype/dart.kak +++ b/rc/filetype/dart.kak @@ -84,7 +84,7 @@ evaluate-commands %sh{ define-command -hidden dart-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line @@ -92,11 +92,11 @@ define-command -hidden dart-indent-on-new-line %~ # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,} yP } + try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for - try %[ execute-keys -draft \;)MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] + try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] = ~ diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index c439880f..9395acb2 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -70,13 +70,13 @@ define-command -hidden elixir-indent-on-new-line %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # indent after line ending with: # try %{ execute-keys -draft k x (do|else|->)$ & } # filter previous line try %{ execute-keys -draft k : elixir-trim-indent } # indent after lines ending with do or -> - try %{ execute-keys -draft \\; k x ^.+(do|->)$ j } + try %{ execute-keys -draft k x ^.+(do|->)$ j } } } diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index b0c1b214..2ba8d68a 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -55,7 +55,7 @@ define-command -hidden elm-trim-indent %{ } define-command -hidden elm-indent-after " - execute-keys -draft \\; k x ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ j + execute-keys -draft k x ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ j " define-command -hidden elm-indent-on-new-line %{ @@ -63,9 +63,9 @@ define-command -hidden elm-indent-on-new-line %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # align to first clause - try %{ execute-keys -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* s \A|.\z & } + try %{ execute-keys -draft k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* s \A|.\z & } # filter previous line try %{ execute-keys -draft k : elm-trim-indent } # indent after lines beginning with condition or ending with expression or =( diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index 49d0c9f8..89c6c8f3 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -58,9 +58,9 @@ define-command -hidden fish-trim-indent %{ define-command -hidden fish-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start and indent when necessary - try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z1 } - try %{ execute-keys -draft ^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } - try %{ execute-keys -draft ^\h*(case)$^\h*(switch)s\A|.\z1 } + try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z1 } + try %{ execute-keys -draft ^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } + try %{ execute-keys -draft ^\h*(case)$^\h*(switch)s\A|.\z1 } } } @@ -69,7 +69,7 @@ define-command -hidden fish-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after start structure diff --git a/rc/filetype/gas.kak b/rc/filetype/gas.kak index 67c25a85..cfcf395b 100644 --- a/rc/filetype/gas.kak +++ b/rc/filetype/gas.kak @@ -87,7 +87,7 @@ define-command -hidden gas-trim-indent %{ define-command -hidden gas-indent-on-new-line %~ evaluate-commands -draft -itersel %< # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : gas-trim-indent } # indent after label diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index 79df696b..69ce6c27 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -76,7 +76,7 @@ evaluate-commands %sh{ define-command -hidden go-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line @@ -84,11 +84,11 @@ define-command -hidden go-indent-on-new-line %~ # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,} yP } + try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for - try %[ execute-keys -draft \;)MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] + try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] = ~ diff --git a/rc/filetype/haml.kak b/rc/filetype/haml.kak index e307363a..6b7d4c72 100644 --- a/rc/filetype/haml.kak +++ b/rc/filetype/haml.kak @@ -61,7 +61,7 @@ define-command -hidden haml-indent-on-new-line %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : haml-trim-indent } # indent after lines beginning with : or - diff --git a/rc/filetype/haskell.kak b/rc/filetype/haskell.kak index 703084cb..5e60d39b 100644 --- a/rc/filetype/haskell.kak +++ b/rc/filetype/haskell.kak @@ -105,13 +105,13 @@ define-command -hidden haskell-indent-on-new-line %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # align to first clause - try %{ execute-keys -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* s \A|.\z & } + try %{ execute-keys -draft k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* s \A|.\z & } # filter previous line try %{ execute-keys -draft k : haskell-trim-indent } # indent after lines beginning with condition or ending with expression or =( - try %{ execute-keys -draft \; k x ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ j } + try %{ execute-keys -draft k x ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ j } } } diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak index 4b1b6b2e..df854076 100644 --- a/rc/filetype/hbs.kak +++ b/rc/filetype/hbs.kak @@ -78,7 +78,7 @@ define-command -hidden hbs-indent-on-new-line %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y j p } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : hbs-trim-indent } # indent after lines beginning with : or - diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak index d6385d10..4a86e21b 100644 --- a/rc/filetype/html.kak +++ b/rc/filetype/html.kak @@ -77,7 +77,7 @@ define-command -hidden html-indent-on-greater-than %[ define-command -hidden html-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : html-trim-indent } # indent after lines ending with opening tag diff --git a/rc/filetype/i3.kak b/rc/filetype/i3.kak index 91dc6d5e..241732bd 100644 --- a/rc/filetype/i3.kak +++ b/rc/filetype/i3.kak @@ -72,7 +72,7 @@ define-command -hidden i3-indent-on-new-line %~ # copy # comments prefix try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { try %[ execute-keys -draft k \{\h*$ j ] # cleanup trailing white spaces on the previous line diff --git a/rc/filetype/java.kak b/rc/filetype/java.kak index 9db24740..829652c4 100644 --- a/rc/filetype/java.kak +++ b/rc/filetype/java.kak @@ -43,7 +43,7 @@ add-highlighter shared/java/code/ regex "(? } + try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line @@ -51,11 +51,11 @@ define-command -hidden java-indent-on-new-line %~ # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,} yP } + try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after keywords - try %[ execute-keys -draft \;)MB \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] + try %[ execute-keys -draft )MB \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] = ~ diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 73894ab3..3dfa4d40 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -57,7 +57,7 @@ define-command -hidden javascript-indent-on-new-line %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : javascript-trim-indent } # indent after lines beginning / ending with opener token diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index 4ea31777..2f798b6f 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -56,7 +56,7 @@ define-command -hidden json-indent-on-char %< define-command -hidden json-indent-on-new-line %< evaluate-commands -draft -itersel %< # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : json-trim-indent } # indent after lines beginning with opener token diff --git a/rc/filetype/just.kak b/rc/filetype/just.kak index f81f0b58..d198d517 100644 --- a/rc/filetype/just.kak +++ b/rc/filetype/just.kak @@ -26,7 +26,7 @@ provide-module justfile %{ define-command -hidden just-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # cleanup trailing white spaces on previous line try %{ execute-keys -draft k s \h+$ "_d } # copy '#' comment prefix and following white spaces diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index 1c558f53..9ee422f9 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -20,7 +20,7 @@ hook global WinSetOption filetype=kak %~ hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } @@ -96,7 +96,7 @@ define-command -hidden kak-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after line ending with %\w*[^\s\w] diff --git a/rc/filetype/ledger.kak b/rc/filetype/ledger.kak index 5130a4a3..5ebe489f 100644 --- a/rc/filetype/ledger.kak +++ b/rc/filetype/ledger.kak @@ -127,7 +127,7 @@ add-highlighter shared/ledger/tag/assert regex '^\h*assert' 0:function define-command -hidden ledger-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent - try %[ execute-keys -draft \; K ] + try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line try %[ execute-keys -draft k s \h+$ d ] # indent after the first line of a transaction @@ -136,7 +136,7 @@ define-command -hidden ledger-indent-on-new-line %[ ] define-command -hidden ledger-trim-indent %{ - try %{ execute-keys -draft \; s ^\h+$ d } + try %{ execute-keys -draft s ^\h+$ d } } ] diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 64a5a5a2..7e9c0657 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -78,8 +78,8 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl define-command -hidden lua-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start and indent when necessary, elseif is already covered by else - try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|\z) } - try %{ execute-keys -draft ^\h*(end)$^\h*(for|function|if|while)s\A|\z) } + try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|\z) } + try %{ execute-keys -draft ^\h*(end)$^\h*(for|function|if|while)s\A|\z) } } } diff --git a/rc/filetype/makefile.kak b/rc/filetype/makefile.kak index 26f4f564..76420ac6 100644 --- a/rc/filetype/makefile.kak +++ b/rc/filetype/makefile.kak @@ -53,7 +53,7 @@ evaluate-commands %sh{ define-command -hidden makefile-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } ## If the line above is a target indent with a tab try %{ execute-keys -draft Z k ^\S.*?(::|:|!)\s z i } # cleanup trailing white space son previous line diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 7f9116da..6483f158 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -89,7 +89,7 @@ define-command -hidden markdown-indent-on-new-line %{ # copy block quote(s), list item prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # remove trailing white spaces try %{ execute-keys -draft -itersel %{ k s \h+$ d } } } diff --git a/rc/filetype/moon.kak b/rc/filetype/moon.kak index b0245ede..28755be6 100644 --- a/rc/filetype/moon.kak +++ b/rc/filetype/moon.kak @@ -88,11 +88,11 @@ define-command -hidden moon-trim-indent %{ define-command -hidden moon-indent-on-char %{ evaluate-commands -draft -itersel %{ # align _else_ statements to start - try %{ execute-keys -draft ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } # align _when_ to _switch_ then indent - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) } + try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) } # align _catch_ and _finally_ to _try_ - try %{ execute-keys -draft ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } } } @@ -101,7 +101,7 @@ define-command -hidden moon-indent-on-new-line %{ # copy -- comment prefix and following white spaces try %{ execute-keys -draft k s ^ \h * \K -- \h * y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : moon-trim-indent } # indent after start structure diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 59fdf225..dff43b18 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -18,7 +18,7 @@ hook global WinSetOption filetype=nim %{ hook window InsertChar \n -group nim-indent nim-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft \; s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } } @@ -111,7 +111,7 @@ def -hidden nim-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ exec -draft k s ^\h*#\h* y jgh P } # preserve previous line indent - try %{ exec -draft \; K } + try %{ exec -draft K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' diff --git a/rc/filetype/nix.kak b/rc/filetype/nix.kak index 4f367195..36137552 100644 --- a/rc/filetype/nix.kak +++ b/rc/filetype/nix.kak @@ -104,7 +104,7 @@ define-command -hidden nix-indent-on-new-line %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : nix-trim-indent } # indent after lines beginning / ending with opener token diff --git a/rc/filetype/perl.kak b/rc/filetype/perl.kak index ce435cc5..17fe1b2a 100644 --- a/rc/filetype/perl.kak +++ b/rc/filetype/perl.kak @@ -93,7 +93,7 @@ add-highlighter shared/perl/code/ regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATO define-command -hidden perl-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line @@ -101,11 +101,11 @@ define-command -hidden perl-indent-on-new-line %~ # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,} yP } + try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for - try %[ execute-keys -draft \;)MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] + try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] = ~ diff --git a/rc/filetype/php.kak b/rc/filetype/php.kak index 158da4e7..e296b4fa 100644 --- a/rc/filetype/php.kak +++ b/rc/filetype/php.kak @@ -86,7 +86,7 @@ define-command -hidden php-indent-on-new-line %< # copy // comments or docblock * prefix and following white spaces try %{ execute-keys -draft s [^/] k s ^\h*\K(?://|[*][^/])\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : php-trim-indent } # indent after lines beginning / ending with opener token diff --git a/rc/filetype/pony.kak b/rc/filetype/pony.kak index 03911aec..535d1976 100644 --- a/rc/filetype/pony.kak +++ b/rc/filetype/pony.kak @@ -18,7 +18,7 @@ hook global WinSetOption filetype=pony %{ hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } diff --git a/rc/filetype/protobuf.kak b/rc/filetype/protobuf.kak index 4e568704..2e7d8f97 100644 --- a/rc/filetype/protobuf.kak +++ b/rc/filetype/protobuf.kak @@ -69,13 +69,13 @@ evaluate-commands %sh{ define-command -hidden protobuf-indent-on-newline %~ evaluate-commands -draft -itersel %[ # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } # indent after lines ending with { try %[ execute-keys -draft k \{\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # copy // comments prefix - try %{ execute-keys -draft \;k s ^\h*\K/{2,}(\h*(?=\S))? yP } + try %{ execute-keys -draft k s ^\h*\K/{2,}(\h*(?=\S))? yP } ] ~ diff --git a/rc/filetype/pug.kak b/rc/filetype/pug.kak index 0b1597e1..42f5611c 100644 --- a/rc/filetype/pug.kak +++ b/rc/filetype/pug.kak @@ -68,7 +68,7 @@ define-command -hidden pug-trim-indent %{ define-command -hidden pug-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : pug-trim-indent } # copy '//', '|', '-' or '(!)=' prefix and following whitespace diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index b88f5343..93f9a618 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -18,7 +18,7 @@ hook global WinSetOption filetype=python %{ hook window InsertChar \n -group python-indent python-indent-on-new-line # cleanup trailing whitespaces on current line insert end - hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } } @@ -145,7 +145,7 @@ define-command -hidden python-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after line ending with : diff --git a/rc/filetype/r.kak b/rc/filetype/r.kak index ced4ad93..80456f22 100644 --- a/rc/filetype/r.kak +++ b/rc/filetype/r.kak @@ -52,11 +52,11 @@ define-command -hidden r-trim-indent %{ } define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel %< - execute-keys \; + execute-keys try %< # if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line - execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?:#[^\n]+)?\n\z mJ 1 + execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?:#[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K @@ -67,7 +67,7 @@ define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel try %< execute-keys -draft k s[{(]\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k s\)\h*(?:#[^\n]+)?\n\z \ - mB \A\b(if|for|while)\b j > + mB \A\b(if|for|while)\b j > try %< execute-keys -draft k s \belse\b\h*(?:#[^\n]+)?\n\z \ j > # deindent after a single line statement end @@ -83,7 +83,7 @@ define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel # Go to opening parenthesis and opening brace, then select the most nested one try %< execute-keys [c [({],[)}] > # Validate selection and get first and last char - execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L + execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L # Remove possibly incorrect indent from new line which was copied from previous line try %< execute-keys -draft s\h+ d > # Now indent and align that new line with the opening parenthesis/brace @@ -108,7 +108,7 @@ define-command -hidden r-indent-on-closing-curly-brace %[ ] define-command -hidden r-insert-on-newline %[ evaluate-commands -itersel -draft %[ - execute-keys \; + execute-keys try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak index 67949a83..85a79b31 100644 --- a/rc/filetype/ragel.kak +++ b/rc/filetype/ragel.kak @@ -65,7 +65,7 @@ define-command -hidden ragel-indent-on-new-line %< # copy _#_ comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : ragel-trim-indent } # indent after lines ending with opener token diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 1bd797d4..6ef7def5 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -139,10 +139,10 @@ define-command -hidden ruby-trim-indent %{ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start - try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) s \A | \z ) } } } @@ -160,7 +160,7 @@ define-command -hidden ruby-indent-on-new-line %{ define-command -hidden ruby-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces - try %{ execute-keys -draft k s '^\h*\K#\h*' y j \; P } + try %{ execute-keys -draft k s '^\h*\K#\h*' y j P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 22178060..61b15483 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -83,7 +83,7 @@ define-command -hidden rust-indent-on-new-line %~ # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : rust-trim-indent } # indent after lines ending with { or ( diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index 8c3212fd..403a47dd 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -58,7 +58,7 @@ define-command -hidden sass-indent-on-new-line %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : sass-trim-indent } # avoid indent after properties and comments diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak index 47c5bbe7..29884d20 100644 --- a/rc/filetype/scala.kak +++ b/rc/filetype/scala.kak @@ -64,7 +64,7 @@ define-command -hidden scala-indent-on-new-line %[ # copy // comments prefix and following white spaces try %[ execute-keys -draft k s ^\h*\K#\h* y gh j P ] # preserve previous line indent - try %[ execute-keys -draft \; K ] + try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : scala-trim-indent ] # indent after lines ending with { diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index 9c362d30..272f2fa8 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -73,7 +73,7 @@ define-command -hidden sh-indent-on-new-line %[ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : sh-trim-indent } diff --git a/rc/filetype/taskpaper.kak b/rc/filetype/taskpaper.kak index 3cd97808..dc93b16f 100644 --- a/rc/filetype/taskpaper.kak +++ b/rc/filetype/taskpaper.kak @@ -43,7 +43,7 @@ add-highlighter shared/taskpaper/ regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) define-command -hidden taskpaper-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent - try %{ execute-keys -draft \;K } + try %{ execute-keys -draft K } ## If the line above is a project indent with a tab try %{ execute-keys -draft Z k ^\h*([^:\n]+): z i } # cleanup trailing white spaces on previous line diff --git a/rc/filetype/toml.kak b/rc/filetype/toml.kak index fa3f58cb..d8377e69 100644 --- a/rc/filetype/toml.kak +++ b/rc/filetype/toml.kak @@ -61,7 +61,7 @@ define-command -hidden toml-indent-on-new-line %{ # copy comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : toml-trim-indent } } diff --git a/rc/filetype/yaml.kak b/rc/filetype/yaml.kak index 9731ff53..d1370785 100644 --- a/rc/filetype/yaml.kak +++ b/rc/filetype/yaml.kak @@ -54,7 +54,7 @@ define-command -hidden yaml-indent-on-new-line %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent - try %{ execute-keys -draft \; K } + try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : yaml-trim-indent } # indent after : diff --git a/src/keys.cc b/src/keys.cc index a424bb42..6343bd19 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -78,6 +78,7 @@ static constexpr KeyAndName keynamemap[] = { { "del", Key::Delete }, { "plus", '+' }, { "minus", '-' }, + { "semicolon", ';' }, }; KeyList parse_keys(StringView str)