src rc: Rename exec/eval into execute-keys/evaluate-commands

This commit is contained in:
Frank LENORMAND 2017-11-03 11:09:45 +03:00
parent c9b280b712
commit 9127ed0d55
59 changed files with 444 additions and 443 deletions

View File

@ -8,16 +8,16 @@ declare-option -docstring %{command to which the paragraphs to wrap will be pass
all occurences of '%c' are replaced with `autowrap_column`} \ all occurences of '%c' are replaced with `autowrap_column`} \
str autowrap_fmtcmd 'fold -s -w %c' str autowrap_fmtcmd 'fold -s -w %c'
define-command -hidden autowrap-cursor %{ eval -save-regs '/"|^@m' %{ define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m' %{
try %{ try %{
## if the line isn't too long, do nothing ## if the line isn't too long, do nothing
exec -draft "<a-x><a-k>^[^\n]{%opt{autowrap_column},}[^\n]<ret>" execute-keys -draft "<a-x><a-k>^[^\n]{%opt{autowrap_column},}[^\n]<ret>"
try %{ try %{
reg m "%val{selections_desc}" reg m "%val{selections_desc}"
## if we're adding characters past the limit, just wrap them around ## if we're adding characters past the limit, just wrap them around
exec -draft "<a-h><a-k>.{%opt{autowrap_column}}\h*[^\s]*<ret>1s(\h+)[^\h]*\z<ret>c<ret>" execute-keys -draft "<a-h><a-k>.{%opt{autowrap_column}}\h*[^\s]*<ret>1s(\h+)[^\h]*\z<ret>c<ret>"
} catch %{ } catch %{
## if we're adding characters in the middle of a sentence, use ## if we're adding characters in the middle of a sentence, use
## the `fmtcmd` command to wrap the entire paragraph ## the `fmtcmd` command to wrap the entire paragraph
@ -27,9 +27,9 @@ define-command -hidden autowrap-cursor %{ eval -save-regs '/"|^@m' %{
format_cmd=$(printf %s "${kak_opt_autowrap_fmtcmd}" \ format_cmd=$(printf %s "${kak_opt_autowrap_fmtcmd}" \
| sed "s/%c/${kak_opt_autowrap_column}/g") | sed "s/%c/${kak_opt_autowrap_column}/g")
printf %s " printf %s "
eval -draft %{ evaluate-commands -draft %{
exec '<a-]>p<a-x><a-j>|${format_cmd}<ret>' execute-keys '<a-]>p<a-x><a-j>|${format_cmd}<ret>'
try %{ exec s\h+$<ret> d } try %{ execute-keys s\h+$<ret> d }
} }
select '${kak_reg_m}' select '${kak_reg_m}'
" "

View File

@ -40,24 +40,24 @@ add-highlighter shared/css/selector regex [*]|[#.][A-Za-z][A-Za-z0-9_-]* 0:varia
define-command -hidden css-filter-around-selections %{ define-command -hidden css-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden css-indent-on-new-line %[ define-command -hidden css-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : css-filter-around-selections <ret> ] try %[ execute-keys -draft k : css-filter-around-selections <ret> ]
# indent after lines ending with with { # indent after lines ending with with {
try %[ exec -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
] ]
] ]
define-command -hidden css-indent-on-closing-curly-brace %[ define-command -hidden css-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ]
] ]
] ]

View File

@ -37,14 +37,14 @@ If no symbol is passed then the current selection is used as symbol name} \
re=$0; re=$0;
sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re); sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re);
keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys); keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys);
out = out " %{" $2 " {MenuInfo}" re "} %{eval -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; exec %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }" out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }"
} }
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{eval -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" } /[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" }
END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }' END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }'
}} }}
define-command ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ eval -draft %{ define-command ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ evaluate-commands -draft %{
exec <space>hb<a-k>^\w+$<ret> execute-keys <space>hb<a-k>^\w+$<ret>
%sh{ { %sh{ {
compl=$(readtags -p "$kak_selection" | cut -f 1 | sort | uniq | sed -e 's/:/\\:/g' | sed -e 's/\n/:/g' ) compl=$(readtags -p "$kak_selection" | cut -f 1 | sort | uniq | sed -e 's/:/\\:/g' | sed -e 's/\n/:/g' )
compl="${kak_cursor_line}.${kak_cursor_column}+${#kak_selection}@${kak_timestamp}:${compl}" compl="${kak_cursor_line}.${kak_cursor_column}+${#kak_selection}@${kak_timestamp}:${compl}"
@ -53,13 +53,13 @@ define-command ctags-complete -docstring "Insert completion candidates for the c
}} }}
define-command ctags-funcinfo -docstring "Display ctags information about a selected function" %{ define-command ctags-funcinfo -docstring "Display ctags information about a selected function" %{
eval -draft %{ evaluate-commands -draft %{
try %{ try %{
exec -no-hooks '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>' execute-keys -no-hooks '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>'
%sh{ %sh{
sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/') sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/')
if [ -n "$sigs" ]; then if [ -n "$sigs" ]; then
printf %s\\n "eval -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}" printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}"
fi fi
} }
} }
@ -90,7 +90,7 @@ define-command ctags-generate -docstring 'Generate tag file asynchronously' %{
msg="tags generation failed" msg="tags generation failed"
fi fi
printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session}
} > /dev/null 2>&1 < /dev/null & } } > /dev/null 2>&1 < /dev/null & }
} }
@ -110,6 +110,6 @@ define-command ctags-update-tags -docstring 'Update tags for the given file' %{
msg="tags update failed for $kak_bufname" msg="tags update failed for $kak_bufname"
fi fi
printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session}
} > /dev/null 2>&1 < /dev/null & } } > /dev/null 2>&1 < /dev/null & }
} }

View File

@ -82,32 +82,32 @@ add-highlighter shared/d/code regex "\b(this)\b\s*[^(]" 1:value
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden d-indent-on-new-line %~ define-command -hidden d-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
define-command -hidden d-indent-on-opening-curly-brace %[ define-command -hidden d-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
define-command -hidden d-indent-on-closing-curly-brace %[ define-command -hidden d-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -117,7 +117,7 @@ hook -group d-highlight global WinSetOption filetype=d %{ add-highlighter window
hook global WinSetOption filetype=d %{ hook global WinSetOption filetype=d %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group d-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group d-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group d-indent d-indent-on-new-line hook window InsertChar \n -group d-indent d-indent-on-new-line
hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace
hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace

View File

@ -30,40 +30,40 @@ add-highlighter shared/fish/code regex \b(and|begin|bg|bind|block|break|breakpoi
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden fish-filter-around-selections %{ define-command -hidden fish-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft <a-x>s\h+$<ret>d } try %{ execute-keys -draft <a-x>s\h+$<ret>d }
} }
} }
define-command -hidden fish-indent-on-char %{ define-command -hidden fish-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start and indent when necessary # align middle and end structures to start and indent when necessary
try %{ exec -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(begin|for|function|if|switch|while)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(begin|for|function|if|switch|while)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(case)$<ret><a-\;><a-?>^\h*(switch)<ret>s\A|\z<ret>'<a-&>'<space><a-gt> } try %{ execute-keys -draft <a-x><a-k>^\h*(case)$<ret><a-\;><a-?>^\h*(switch)<ret>s\A|\z<ret>'<a-&>'<space><a-gt> }
} }
} }
define-command -hidden fish-indent-on-new-line %{ define-command -hidden fish-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space>K<a-&> } try %{ execute-keys -draft <space>K<a-&> }
# filter previous line # filter previous line
try %{ exec -draft k:fish-filter-around-selections<ret> } try %{ execute-keys -draft k:fish-filter-around-selections<ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k<a-x><a-k>^\h*(begin|case|else|for|function|if|switch|while)\b<ret>j<a-gt> } try %{ execute-keys -draft k<a-x><a-k>^\h*(begin|case|else|for|function|if|switch|while)\b<ret>j<a-gt> }
} }
} }
define-command -hidden fish-insert-on-new-line %{ define-command -hidden fish-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k<a-x>s^\h*\K#\h*<ret>yjp } try %{ execute-keys -draft k<a-x>s^\h*\K#\h*<ret>yjp }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' } try %{ execute-keys -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' }
try %{ exec -draft k<a-x><a-k>^<c-r>x(begin|for|function|if|switch|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(begin|for|function|if|switch|while).*\n<c-r>xend$<ret>jxypjaend<esc><a-lt> } try %{ execute-keys -draft k<a-x><a-k>^<c-r>x(begin|for|function|if|switch|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(begin|for|function|if|switch|while).*\n<c-r>xend$<ret>jxypjaend<esc><a-lt> }
} }
} }
} }

View File

@ -67,21 +67,21 @@ add-highlighter shared/gas/code regex \
^\h*(vxorp[sd]|vandp[sd]|ucomis[sd])\b 0:keyword ^\h*(vxorp[sd]|vandp[sd]|ucomis[sd])\b 0:keyword
define-command -hidden gas-filter-around-selections %{ define-command -hidden gas-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h+$ <ret> d } try %{ execute-keys -draft s \h+$ <ret> d }
} }
} }
define-command -hidden gas-indent-on-new-line %~ define-command -hidden gas-indent-on-new-line %~
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : gas-filter-around-selections <ret> } try %{ execute-keys -draft k : gas-filter-around-selections <ret> }
# indent after label # indent after label
try %[ exec -draft k <a-x> <a-k> :$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> :$ <ret> j <a-gt> ]
> >
~ ~

View File

@ -54,32 +54,32 @@ add-highlighter shared/go/code regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9]+|0[xX][0-9
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden go-indent-on-new-line %~ define-command -hidden go-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
define-command -hidden go-indent-on-opening-curly-brace %[ define-command -hidden go-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
define-command -hidden go-indent-on-closing-curly-brace %[ define-command -hidden go-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -89,7 +89,7 @@ hook -group go-highlight global WinSetOption filetype=go %{ add-highlighter wind
hook global WinSetOption filetype=go %{ hook global WinSetOption filetype=go %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group go-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group go-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group go-indent go-indent-on-new-line hook window InsertChar \n -group go-indent go-indent-on-new-line
hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace
hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace

View File

@ -74,21 +74,21 @@ add-highlighter shared/haskell/code regex \B'([^\\]|[\\]['"\w\d\\])' 0:string
define-command -hidden haskell-filter-around-selections %{ define-command -hidden haskell-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden haskell-indent-on-new-line %{ define-command -hidden haskell-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# align to first clause # align to first clause
try %{ exec -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* <ret> s \A|.\z <ret> & } 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.* <ret> s \A|.\z <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : haskell-filter-around-selections <ret> } try %{ execute-keys -draft k : haskell-filter-around-selections <ret> }
# indent after lines beginning with condition or ending with expression or =( # indent after lines beginning with condition or ending with expression or =(
try %{ exec -draft \; k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> } try %{ execute-keys -draft \; k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> }
} }
} }

View File

@ -41,24 +41,24 @@ add-highlighter shared/html/tag/content/string fill string
define-command -hidden html-filter-around-selections %{ define-command -hidden html-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden html-indent-on-greater-than %[ define-command -hidden html-indent-on-greater-than %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align closing tag to opening when alone on a line # align closing tag to opening when alone on a line
try %[ exec -draft <space> <a-h> s ^\h+<lt>/(\w+)<gt>$ <ret> {c<lt><c-r>1,<lt>/<c-r>1<gt> <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <space> <a-h> s ^\h+<lt>/(\w+)<gt>$ <ret> {c<lt><c-r>1,<lt>/<c-r>1<gt> <ret> s \A|.\z <ret> 1<a-&> ]
] ]
] ]
define-command -hidden html-indent-on-new-line %{ define-command -hidden html-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : html-filter-around-selections <ret> } try %{ execute-keys -draft k : html-filter-around-selections <ret> }
# indent after lines ending with opening tag # indent after lines ending with opening tag
try %{ exec -draft k <a-x> <a-k> <[^/][^>]+>$ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> <[^/][^>]+>$ <ret> j <a-gt> }
} }
} }

View File

@ -19,39 +19,39 @@ add-highlighter shared/java/code regex "\b(final|public|protected|private|abstra
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden java-indent-on-new-line %~ define-command -hidden java-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after keywords # indent after keywords
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
define-command -hidden java-indent-on-opening-curly-brace %[ define-command -hidden java-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
define-command -hidden java-indent-on-closing-curly-brace %[ define-command -hidden java-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=java %{ hook global WinSetOption filetype=java %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group java-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group java-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group java-indent java-indent-on-new-line hook window InsertChar \n -group java-indent java-indent-on-new-line
hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace
hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace

View File

@ -41,26 +41,26 @@ add-highlighter shared/javascript/code regex \b(async|await|break|case|catch|cla
define-command -hidden javascript-filter-around-selections %{ define-command -hidden javascript-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden javascript-indent-on-char %< define-command -hidden javascript-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
define-command -hidden javascript-indent-on-new-line %< define-command -hidden javascript-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : javascript-filter-around-selections <ret> } try %{ execute-keys -draft k : javascript-filter-around-selections <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ exec -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
> >
> >

View File

@ -23,24 +23,24 @@ add-highlighter shared/json/code regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+
define-command -hidden json-filter-around-selections %{ define-command -hidden json-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden json-indent-on-char %< define-command -hidden json-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> >
> >
> >
define-command -hidden json-indent-on-new-line %< define-command -hidden json-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : json-filter-around-selections <ret> } try %{ execute-keys -draft k : json-filter-around-selections <ret> }
# indent after lines beginning with opener token # indent after lines beginning with opener token
try %< exec -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> >
> >
> >

View File

@ -10,9 +10,9 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX)
mkfifo "$dir"/fifo mkfifo "$dir"/fifo
printf '%s\n' "eval -no-hooks write $dir/buf" printf '%s\n' "evaluate-commands -no-hooks write $dir/buf"
printf '%s\n' "eval -draft %{ printf '%s\n' "evaluate-commands -draft %{
edit! -fifo $dir/fifo -debug *lint-output* edit! -fifo $dir/fifo -debug *lint-output*
set-option buffer filetype make set-option buffer filetype make
set-option buffer make_current_error_line 0 set-option buffer make_current_error_line 0
@ -24,8 +24,8 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{
{ # do the parsing in the background and when ready send to the session { # do the parsing in the background and when ready send to the session
eval "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2,2 -n > "$dir"/stderr evaluate-commands "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2,2 -n > "$dir"/stderr
printf '%s\n' "eval -client $kak_client echo 'linting done'" | kak -p "$kak_session" printf '%s\n' "evaluate-commands -client $kak_client echo 'linting done'" | kak -p "$kak_session"
# Flags for the gutter: # Flags for the gutter:
# line3|{red}:line11|{yellow} # line3|{red}:line11|{yellow}

View File

@ -28,15 +28,15 @@ add-highlighter shared/lisp/code regex \b(def[a-z]+|if|do|let|lambda|catch|and|a
define-command -hidden lisp-filter-around-selections %{ define-command -hidden lisp-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden lisp-indent-on-new-line %{ define-command -hidden lisp-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# indent when matches opening paren # indent when matches opening paren
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> }
} }
} }

View File

@ -52,39 +52,39 @@ define-command lua-alternative-file -docstring 'Jump to the alternate file (impl
}} }}
define-command -hidden lua-filter-around-selections %{ define-command -hidden lua-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft <a-x>s\h+$<ret>d } try %{ execute-keys -draft <a-x>s\h+$<ret>d }
} }
} }
define-command -hidden lua-indent-on-char %{ define-command -hidden lua-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start and indent when necessary, elseif is already covered by else # align middle and end structures to start and indent when necessary, elseif is already covered by else
try %{ exec -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(else)$<ret><a-\;><a-?>^\h*(if)<ret>s\A|\z<ret>'<a-&> }
try %{ exec -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(for|function|if|while)<ret>s\A|\z<ret>'<a-&> } try %{ execute-keys -draft <a-x><a-k>^\h*(end)$<ret><a-\;><a-?>^\h*(for|function|if|while)<ret>s\A|\z<ret>'<a-&> }
} }
} }
define-command -hidden lua-indent-on-new-line %{ define-command -hidden lua-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space>K<a-&> } try %{ execute-keys -draft <space>K<a-&> }
# filter previous line # filter previous line
try %{ exec -draft k:lua-filter-around-selections<ret> } try %{ execute-keys -draft k:lua-filter-around-selections<ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k<a-x><a-k>^\h*(else|elseif|for|function|if|while)\b<ret>j<a-gt> } try %{ execute-keys -draft k<a-x><a-k>^\h*(else|elseif|for|function|if|while)\b<ret>j<a-gt> }
} }
} }
define-command -hidden lua-insert-on-new-line %{ define-command -hidden lua-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy -- comment prefix and following white spaces # copy -- comment prefix and following white spaces
try %{ exec -draft k<a-x>s^\h*\K--\h*<ret>yghjP } try %{ execute-keys -draft k<a-x>s^\h*\K--\h*<ret>yghjP }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' } try %{ execute-keys -draft k<a-x>s^\h+<ret>"xy } catch %{ reg x '' }
try %{ exec -draft k<a-x><a-k>^<c-r>x(for|function|if|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(for|function|if|while).*\n<c-r>x(else|end|elseif[^\n]*)$<ret>jxypjaend<esc><a-lt> } try %{ execute-keys -draft k<a-x><a-k>^<c-r>x(for|function|if|while)<ret>j<a-a>iX<a-\;>K<a-K>^<c-r>x(for|function|if|while).*\n<c-r>x(else|end|elseif[^\n]*)$<ret>jxypjaend<esc><a-lt> }
} }
} }
} }

View File

@ -124,13 +124,13 @@ add-highlighter shared/markdown/content regex \H\K\h\h$ 0:PrimarySelection
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden markdown-indent-on-new-line %{ define-command -hidden markdown-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy block quote(s), list item prefix and following white spaces # copy block quote(s), list item prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel %{ k<a-x> s \h+$ <ret> d } } try %{ execute-keys -draft -itersel %{ k<a-x> s \h+$ <ret> d } }
} }
} }

View File

@ -24,8 +24,8 @@ add-highlighter shared/ocaml/comment fill comment
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden ocaml-indent-on-char %{ define-command -hidden ocaml-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
exec ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>" execute-keys ";i<space><esc>Gg|ocp-indent --config base=%opt{indentwidth} --indent-empty --lines %val{cursor_line}<ret>"
} }
} }

View File

@ -71,32 +71,32 @@ add-highlighter shared/perl/code regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden perl-indent-on-new-line %~ define-command -hidden perl-indent-on-new-line %~
eval -draft -itersel %= evaluate-commands -draft -itersel %=
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> [{(]\h*$ <ret> j<a-gt> ]
# cleanup trailing white spaces on the previous line # cleanup trailing white spaces on the previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> } try %{ execute-keys -draft \;<c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o><c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ exec -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ exec -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft \;<a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
= =
~ ~
define-command -hidden perl-indent-on-opening-curly-brace %[ define-command -hidden perl-indent-on-opening-curly-brace %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\' <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\' <ret> s \A|.\z <ret> 1<a-&> ]
] ]
define-command -hidden perl-indent-on-closing-curly-brace %[ define-command -hidden perl-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization # Initialization
@ -106,7 +106,7 @@ hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter
hook global WinSetOption filetype=perl %{ hook global WinSetOption filetype=perl %{
# cleanup trailing whitespaces when exiting insert mode # cleanup trailing whitespaces when exiting insert mode
hook window InsertEnd .* -group perl-hooks %{ try %{ exec -draft <a-x>s^\h+$<ret>d } } hook window InsertEnd .* -group perl-hooks %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group perl-indent perl-indent-on-new-line hook window InsertChar \n -group perl-indent perl-indent-on-new-line
hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace
hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace

View File

@ -101,42 +101,42 @@ define-command ruby-alternative-file -docstring 'Jump to the alternate file (imp
}} }}
define-command -hidden ruby-filter-around-selections %{ define-command -hidden ruby-filter-around-selections %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
define-command -hidden ruby-indent-on-char %{ define-command -hidden ruby-indent-on-char %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# align middle and end structures to start # align middle and end structures to start
try %{ exec -draft <a-x> <a-k> ^ \h * (else|elsif) $ <ret> <a-\;> <a-?> ^ \h * (if) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (else|elsif) $ <ret> <a-\;> <a-?> ^ \h * (if) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (case) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (case) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (rescue) $ <ret> <a-\;> <a-?> ^ \h * (begin) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (rescue) $ <ret> <a-\;> <a-?> ^ \h * (begin) <ret> s \A | \z <ret> \' <a-&> }
try %{ exec -draft <a-x> <a-k> ^ \h * (end) $ <ret> <a-\;> <a-?> ^ \h * (begin|case|class|def|do|for|if|module|unless|until|while) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (end) $ <ret> <a-\;> <a-?> ^ \h * (begin|case|class|def|do|for|if|module|unless|until|while) <ret> s \A | \z <ret> \' <a-&> }
} }
} }
define-command -hidden ruby-indent-on-new-line %{ define-command -hidden ruby-indent-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft K <a-&> } try %{ execute-keys -draft K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : ruby-filter-around-selections <ret> } try %{ execute-keys -draft k : ruby-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> }
} }
} }
define-command -hidden ruby-insert-on-new-line %{ define-command -hidden ruby-insert-on-new-line %{
eval -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P } try %{ execute-keys -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
# wisely add end structure # wisely add end structure
eval -save-regs x %{ evaluate-commands -save-regs x %{
try %{ exec -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' } try %{ execute-keys -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' }
try %{ exec -draft k <a-x> <a-k> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) <ret> j <a-a> i X <a-\;> K <a-K> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) . * \n <c-r> x end $ <ret> j x y p j a end <esc> <a-lt> } try %{ execute-keys -draft k <a-x> <a-k> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) <ret> j <a-a> i X <a-\;> K <a-K> ^ <c-r> x (begin|case|class|def|do|for|if|module|unless|until|while) . * \n <c-r> x end $ <ret> j x y p j a end <esc> <a-lt> }
} }
} }
} }

View File

@ -36,35 +36,35 @@ add-highlighter shared/rust/code regex \b(?:u8|u16|u32|u64|usize|i8|i16|i32|i64|
define-command -hidden rust-filter-around-selections %{ define-command -hidden rust-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden rust-indent-on-new-line %~ define-command -hidden rust-indent-on-new-line %~
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K//\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K//\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : rust-filter-around-selections <ret> } try %{ execute-keys -draft k : rust-filter-around-selections <ret> }
# indent after lines ending with { or ( # indent after lines ending with { or (
try %[ exec -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> & }
> >
~ ~
define-command -hidden rust-indent-on-opening-curly-brace %[ define-command -hidden rust-indent-on-opening-curly-brace %[
eval -draft -itersel %_ evaluate-commands -draft -itersel %_
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
_ _
] ]
define-command -hidden rust-indent-on-closing-curly-brace %[ define-command -hidden rust-indent-on-closing-curly-brace %[
eval -draft -itersel %_ evaluate-commands -draft -itersel %_
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z <ret> 1<a-&> ]
_ _
] ]

View File

@ -36,26 +36,26 @@ add-highlighter shared/scala/code regex "'[_A-Za-z0-9$]+" 0:variable
define-command -hidden scala-filter-around-selections %{ define-command -hidden scala-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden scala-indent-on-new-line %[ define-command -hidden scala-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %[ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ] try %[ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : scala-filter-around-selections <ret> ] try %[ execute-keys -draft k : scala-filter-around-selections <ret> ]
# indent after lines ending with { # indent after lines ending with {
try %[ exec -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
] ]
] ]
define-command -hidden scala-indent-on-closing-curly-brace %[ define-command -hidden scala-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ]
] ]
] ]

View File

@ -109,7 +109,7 @@ define-command spell-replace %{ %sh{
menu=$(printf %s "${suggestions#?}" | awk -F', ' ' menu=$(printf %s "${suggestions#?}" | awk -F', ' '
{ {
for (i=1; i<=NF; i++) for (i=1; i<=NF; i++)
printf "%s", "%{"$i"}" "%{exec -itersel c"$i"<esc>be}" printf "%s", "%{"$i"}" "%{execute-keys -itersel c"$i"<esc>be}"
} }
') ')
printf 'try %%{ menu -auto-single %s }' "${menu}" printf 'try %%{ menu -auto-single %s }' "${menu}"

View File

@ -45,7 +45,7 @@ If no client is passed then the current one is used} \
-params ..1 -client-completion \ -params ..1 -client-completion \
tmux-focus %{ %sh{ tmux-focus %{ %sh{
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus" printf %s\\n "evaluate-commands -client '$1' focus"
elif [ -n "${kak_client_env_TMUX}" ]; then elif [ -n "${kak_client_env_TMUX}" ]; then
TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null
fi fi

View File

@ -39,7 +39,7 @@ If no client is passed, then the current client is used} \
-params ..1 -client-completion \ -params ..1 -client-completion \
x11-focus %{ %sh{ x11-focus %{ %sh{
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus" printf %s\\n "evaluate-commands -client '$1' focus"
else else
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
fi fi

View File

@ -30,19 +30,19 @@ add-highlighter shared/yaml/code regex ^\h*-?\h*(\S+): 1:attribute
define-command -hidden yaml-filter-around-selections %{ define-command -hidden yaml-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden yaml-indent-on-new-line %{ define-command -hidden yaml-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : yaml-filter-around-selections <ret> } try %{ execute-keys -draft k : yaml-filter-around-selections <ret> }
# indent after : # indent after :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> :$ <ret> j <a-gt> }
} }
} }

View File

@ -12,7 +12,7 @@ hook global BufCreate .*\.c$ %{
hook global BufCreate .*\.h$ %{ hook global BufCreate .*\.h$ %{
try %{ try %{
exec -draft %{%s\b::\b|\btemplate\h*<lt>|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:<ret>} execute-keys -draft %{%s\b::\b|\btemplate\h*<lt>|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:<ret>}
set-option buffer filetype cpp set-option buffer filetype cpp
} catch %{ } catch %{
set-option buffer filetype c set-option buffer filetype c
@ -23,103 +23,103 @@ hook global BufCreate .*\.m %{
set-option buffer filetype objc set-option buffer filetype objc
} }
define-command -hidden c-family-trim-autoindent %[ eval -draft -itersel %[ define-command -hidden c-family-trim-autoindent %[ evaluate-commands -draft -itersel %[
# remove the line if it's empty when leaving the insert mode # remove the line if it's empty when leaving the insert mode
try %[ exec <a-x> 1s^(\h+)$<ret> d ] try %[ execute-keys <a-x> 1s^(\h+)$<ret> d ]
] ] ] ]
define-command -hidden c-family-indent-on-newline %< eval -draft -itersel %< define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -itersel %<
exec \; execute-keys \;
try %< try %<
# if previous line closed a paren, copy indent of the opening paren line # if previous line closed a paren, copy indent of the opening paren line
exec -draft k<a-x> 1s(\))(\h+\w+)*\h*(\;\h*)?$<ret> m<a-\;>J s\A|.\z<ret> 1<a-&> execute-keys -draft k<a-x> 1s(\))(\h+\w+)*\h*(\;\h*)?$<ret> m<a-\;>J s\A|.\z<ret> 1<a-&>
> catch %< > catch %<
# else indent new lines with the same level as the previous one # else indent new lines with the same level as the previous one
exec -draft K <a-&> execute-keys -draft K <a-&>
> >
# remove previous empty lines resulting from the automatic indent # remove previous empty lines resulting from the automatic indent
try %< exec -draft k <a-x> <a-k>^\h+$<ret> Hd > try %< execute-keys -draft k <a-x> <a-k>^\h+$<ret> Hd >
# indent after an opening brace # indent after an opening brace
try %< exec -draft k <a-x> s\{\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> s\{\h*$<ret> j <a-gt> >
# indent after a label # indent after a label
try %< exec -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> >
# indent after a statement not followed by an opening brace # indent after a statement not followed by an opening brace
try %< exec -draft k <a-x> <a-k>\b(if|else|for|while)\h*\(.+?\)\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k>\b(if|else|for|while)\h*\(.+?\)\h*$<ret> j <a-gt> >
# align to the opening parenthesis or opening brace (whichever is first) # align to the opening parenthesis or opening brace (whichever is first)
# on a previous line if its followed by text on the same line # on a previous line if its followed by text on the same line
try %< eval -draft %< try %< evaluate-commands -draft %<
# Go to opening parenthesis and opening brace, then select the most nested one # Go to opening parenthesis and opening brace, then select the most nested one
try %< try %< exec [bZ<a-\;>[B<a-z><gt> > catch %< exec [B > > try %< try %< execute-keys [bZ<a-\;>[B<a-z><gt> > catch %< execute-keys [B > >
# Validate selection and get first and last char # Validate selection and get first and last char
exec <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L s\A|.\z<ret> execute-keys <a-k>\A[{(](\h*\S+)+\n<ret> <a-:><a-\;>L s\A|.\z<ret>
# Remove eventual indent from new line # Remove eventual indent from new line
try %< exec -draft <space> <a-h> s\h+<ret> d > try %< execute-keys -draft <space> <a-h> s\h+<ret> d >
# Now align that new line with the opening parenthesis/brace # Now align that new line with the opening parenthesis/brace
exec & execute-keys &
> > > >
> > > >
define-command -hidden c-family-indent-on-opening-curly-brace %[ 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 # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft -itersel h<a-F>)M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
define-command -hidden c-family-indent-on-closing-curly-brace %[ define-command -hidden c-family-indent-on-closing-curly-brace %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-:><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
define-command -hidden c-family-insert-on-closing-curly-brace %[ define-command -hidden c-family-insert-on-closing-curly-brace %[
# add a semicolon after a closing brace if part of a class, union or struct definition # add a semicolon after a closing brace if part of a class, union or struct definition
try %[ exec -itersel -draft hm<a-x>B<a-x><a-k>\A\h*(class|struct|union|enum)<ret> a\;<esc> ] try %[ execute-keys -itersel -draft hm<a-x>B<a-x><a-k>\A\h*(class|struct|union|enum)<ret> a\;<esc> ]
] ]
define-command -hidden c-family-insert-on-newline %[ eval -draft %[ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -draft %[
exec \; execute-keys \;
try %[ try %[
eval -draft %[ evaluate-commands -draft %[
# copy the commenting prefix # copy the commenting prefix
exec -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y execute-keys -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y
try %[ try %[
# if the previous comment isn't empty, create a new one # if the previous comment isn't empty, create a new one
exec <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P execute-keys <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P
] catch %[ ] catch %[
# if there is no text in the previous comment, remove it completely # if there is no text in the previous comment, remove it completely
exec d execute-keys d
] ]
] ]
] ]
try %[ try %[
# if the previous line isn't within a comment scope, break # if the previous line isn't within a comment scope, break
exec -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret> execute-keys -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret>
# find comment opening, validate it was not closed, and check its using star prefixes # find comment opening, validate it was not closed, and check its using star prefixes
exec -draft <a-?>/\*<ret><a-H> <a-K>\*/<ret> <a-k>\A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z<ret> execute-keys -draft <a-?>/\*<ret><a-H> <a-K>\*/<ret> <a-k>\A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z<ret>
try %[ try %[
# if the previous line is opening the comment, insert star preceeded by space # if the previous line is opening the comment, insert star preceeded by space
exec -draft k<a-x><a-k>^\h*/\*<ret> execute-keys -draft k<a-x><a-k>^\h*/\*<ret>
exec -draft i<space>*<space><esc> execute-keys -draft i<space>*<space><esc>
] catch %[ ] catch %[
try %[ try %[
# if the next line is a comment line insert a star # if the next line is a comment line insert a star
exec -draft j<a-x><a-k>^\h+\*<ret> execute-keys -draft j<a-x><a-k>^\h+\*<ret>
exec -draft i*<space><esc> execute-keys -draft i*<space><esc>
] catch %[ ] catch %[
try %[ try %[
# if the previous line is an empty comment line, close the comment scope # if the previous line is an empty comment line, close the comment scope
exec -draft k<a-x><a-k>^\h+\*\h+$<ret> <a-x>1s\*(\h*)<ret>c/<esc> execute-keys -draft k<a-x><a-k>^\h+\*\h+$<ret> <a-x>1s\*(\h*)<ret>c/<esc>
] catch %[ ] catch %[
# if the previous line is a non-empty comment line, add a star # if the previous line is a non-empty comment line, add a star
exec -draft i*<space><esc> execute-keys -draft i*<space><esc>
] ]
] ]
] ]
# trim trailing whitespace on the previous line # trim trailing whitespace on the previous line
try %[ exec -draft 1s(\h+)$<ret>d ] try %[ execute-keys -draft 1s(\h+)$<ret>d ]
# align the new star with the previous one # align the new star with the previous one
exec J<a-x>1s^[^*]*(\*)<ret>& execute-keys J<a-x>1s^[^*]*(\*)<ret>&
] ]
] ] ] ]
@ -288,10 +288,10 @@ define-command -hidden c-family-insert-include-guards %{
%sh{ %sh{
case "${kak_opt_c_include_guard_style}" in case "${kak_opt_c_include_guard_style}" in
ifdef) ifdef)
echo 'exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>' echo 'execute-keys ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>'
;; ;;
pragma) pragma)
echo 'exec ggi#pragma<space>once<esc>' echo 'execute-keys ggi#pragma<space>once<esc>'
;; ;;
*);; *);;
esac esac

View File

@ -96,7 +96,7 @@ hook global BufSetOption filetype=ruby %{
define-command comment-block -docstring '(un)comment selected lines using block comments' %{ define-command comment-block -docstring '(un)comment selected lines using block comments' %{
%sh{ %sh{
exec_proof() { exec_proof() {
## Replace the '<' sign that is interpreted differently in `exec` ## Replace the '<' sign that is interpreted differently in `execute-keys`
printf %s\\n "$@" | sed 's,<,<lt>,g' printf %s\\n "$@" | sed 's,<,<lt>,g'
} }
@ -108,19 +108,19 @@ define-command comment-block -docstring '(un)comment selected lines using block
exit exit
fi fi
printf %s\\n "eval -draft %{ try %{ printf %s\\n "evaluate-commands -draft %{ try %{
## The selection is empty ## The selection is empty
exec <a-K>\\A[\\h\\v\\n]*\\z<ret> execute-keys <a-K>\\A[\\h\\v\\n]*\\z<ret>
try %{ try %{
## The selection has already been commented ## The selection has already been commented
exec %{<a-K>\\A\\Q${opening}\\E.*\\Q${closing}\\E\\n*\\z<ret>} execute-keys %{<a-K>\\A\\Q${opening}\\E.*\\Q${closing}\\E\\n*\\z<ret>}
## Comment the selection ## Comment the selection
exec -draft %{a${closing}<esc>i${opening}} execute-keys -draft %{a${closing}<esc>i${opening}}
} catch %{ } catch %{
## Uncomment the commented selection ## Uncomment the commented selection
exec -draft %{s(\\A\\Q${opening}\\E)|(\\Q${closing}\\E\\n*\\z)<ret>d} execute-keys -draft %{s(\\A\\Q${opening}\\E)|(\\Q${closing}\\E\\n*\\z)<ret>d}
} }
} }" } }"
} }
@ -136,23 +136,23 @@ define-command comment-line -docstring '(un)comment selected lines using line co
exit exit
fi fi
printf %s\\n "eval -draft %{ printf %s\\n "evaluate-commands -draft %{
## Select the content of the lines, without indentation ## Select the content of the lines, without indentation
exec <a-s>I<esc><a-l> execute-keys <a-s>I<esc><a-l>
try %{ try %{
## Theres no text on the line ## Theres no text on the line
exec <a-K>\\A[\\h\\v\\n]*\\z<ret> execute-keys <a-K>\\A[\\h\\v\\n]*\\z<ret>
try %{ try %{
## The line has already been commented ## The line has already been commented
exec %{<a-K>\\A${opening_escaped}<ret>} execute-keys %{<a-K>\\A${opening_escaped}<ret>}
## Comment the line ## Comment the line
exec -draft %{i${opening}} execute-keys -draft %{i${opening}}
} catch %{ } catch %{
## Uncomment the line ## Uncomment the line
exec -draft %{s\\A${opening_escaped}\\h*<ret>d} execute-keys -draft %{s\\A${opening_escaped}\\h*<ret>d}
} }
} }
}" }"

View File

@ -4,10 +4,10 @@ declare-option -docstring "name of the client in which documentation is to be di
declare-option -hidden range-specs doc_render_ranges declare-option -hidden range-specs doc_render_ranges
define-command -hidden -params 4 doc-render-regex %{ define-command -hidden -params 4 doc-render-regex %{
eval -draft %{ try %{ evaluate-commands -draft %{ try %{
exec \%s %arg{1} <ret> execute-keys \%s %arg{1} <ret>
exec -draft s %arg{2} <ret> d execute-keys -draft s %arg{2} <ret> d
exec "%arg{3}" execute-keys "%arg{3}"
%sh{ %sh{
ranges=$(echo "$kak_selections_desc" | sed -e "s/:/|$4:/g; s/\$/|$4/") ranges=$(echo "$kak_selections_desc" | sed -e "s/:/|$4:/g; s/\$/|$4/")
echo "update-option buffer doc_render_ranges" echo "update-option buffer doc_render_ranges"
@ -18,13 +18,13 @@ define-command -hidden -params 4 doc-render-regex %{
define-command -params 1 -hidden doc-render %{ define-command -params 1 -hidden doc-render %{
edit! -scratch *doc* edit! -scratch *doc*
exec "!cat %arg{1}<ret>gg" execute-keys "!cat %arg{1}<ret>gg"
# Join paragraphs together # Join paragraphs together
try %{ exec -draft \%S \n{2,}|(?<=\+)\n|^[^\n]+::\n <ret> <a-K>^-{2,}(\n|\z)<ret> S\n\z<ret> <a-k>\n<ret> <a-j> } try %{ execute-keys -draft \%S \n{2,}|(?<=\+)\n|^[^\n]+::\n <ret> <a-K>^-{2,}(\n|\z)<ret> S\n\z<ret> <a-k>\n<ret> <a-j> }
# Remove some line end markers # Remove some line end markers
try %{ exec -draft \%s \h*(\+|:{2,})$ <ret> d } try %{ execute-keys -draft \%s \h*(\+|:{2,})$ <ret> d }
# Setup the doc_render_ranges option # Setup the doc_render_ranges option
set-option buffer doc_render_ranges %val{timestamp} set-option buffer doc_render_ranges %val{timestamp}
@ -37,7 +37,7 @@ define-command -params 1 -hidden doc-render %{
doc-render-regex <lt><lt>.*?<gt><gt> <lt><lt>.*,|<gt><gt> 'H' link doc-render-regex <lt><lt>.*?<gt><gt> <lt><lt>.*,|<gt><gt> 'H' link
# Remove escaping of * and ` # Remove escaping of * and `
try %{ exec -draft \%s \\((?=\*)|(?=`)) <ret> d } try %{ execute-keys -draft \%s \\((?=\*)|(?=`)) <ret> d }
set-option buffer readonly true set-option buffer readonly true
add-highlighter buffer ranges doc_render_ranges add-highlighter buffer ranges doc_render_ranges
@ -57,7 +57,7 @@ An optional keyword argument can be passed to the function, which will be automa
shift shift
if [ -f "${page}" ]; then if [ -f "${page}" ]; then
printf %s\\n "eval -try-client %opt{docsclient} doc-render ${page}" printf %s\\n "evaluate-commands -try-client %opt{docsclient} doc-render ${page}"
else else
printf %s\\n "echo -markup '{Error}No such doc file: ${page}'" printf %s\\n "echo -markup '{Error}No such doc file: ${page}'"
fi fi

View File

@ -1,7 +1,7 @@
declare-option -docstring "shell command to which the contents of the current buffer is piped" \ declare-option -docstring "shell command to which the contents of the current buffer is piped" \
str formatcmd str formatcmd
define-command format -docstring "Format the contents of the current buffer" %{ eval -draft %{ define-command format -docstring "Format the contents of the current buffer" %{ evaluate-commands -draft %{
%sh{ %sh{
if [ -n "${kak_opt_formatcmd}" ]; then if [ -n "${kak_opt_formatcmd}" ]; then
path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX) path_file_tmp=$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX)
@ -12,11 +12,11 @@ define-command format -docstring "Format the contents of the current buffer" %{
readonly path_file_out=\$(mktemp \"${TMPDIR:-/tmp}\"/kak-formatter-XXXXXX) readonly path_file_out=\$(mktemp \"${TMPDIR:-/tmp}\"/kak-formatter-XXXXXX)
if cat \"${path_file_tmp}\" | eval \"${kak_opt_formatcmd}\" > \"\${path_file_out}\"; then if cat \"${path_file_tmp}\" | eval \"${kak_opt_formatcmd}\" > \"\${path_file_out}\"; then
printf '%s\\n' \"exec \\%|cat<space>'\${path_file_out}'<ret>\" printf '%s\\n' \"execute-keys \\%|cat<space>'\${path_file_out}'<ret>\"
printf '%s\\n' \"%sh{ rm -f '\${path_file_out}' }\" printf '%s\\n' \"%sh{ rm -f '\${path_file_out}' }\"
else else
printf '%s\\n' \" printf '%s\\n' \"
eval -client '${kak_client}' echo -markup '{Error}formatter returned an error (\$?)' evaluate-commands -client '${kak_client}' echo -markup '{Error}formatter returned an error (\$?)'
\" \"
rm -f \"\${path_file_out}\" rm -f \"\${path_file_out}\"
fi fi
@ -25,7 +25,7 @@ define-command format -docstring "Format the contents of the current buffer" %{
} }
" "
else else
printf '%s\n' "eval -client '${kak_client}' echo -markup '{Error}formatcmd option not specified'" printf '%s\n' "evaluate-commands -client '${kak_client}' echo -markup '{Error}formatcmd option not specified'"
fi fi
} }
} } } }

View File

@ -16,7 +16,7 @@ All the optional arguments are forwarded to the grep utility} \
( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
fi fi
printf %s\\n "eval -try-client '$kak_opt_toolsclient' %{ printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
edit! -fifo ${output} -scroll *grep* edit! -fifo ${output} -scroll *grep*
set-option buffer filetype grep set-option buffer filetype grep
set-option buffer grep_current_line 0 set-option buffer grep_current_line 0
@ -47,34 +47,34 @@ declare-option -docstring "name of the client in which all source code jumps wil
str jumpclient str jumpclient
define-command -hidden grep-jump %{ define-command -hidden grep-jump %{
eval -collapse-jumps %{ evaluate-commands -collapse-jumps %{
try %{ try %{
exec '<a-x>s^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>' execute-keys '<a-x>s^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>'
set-option buffer grep_current_line %val{cursor_line} set-option buffer grep_current_line %val{cursor_line}
eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3} evaluate-commands -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3}
try %{ focus %opt{jumpclient} } try %{ focus %opt{jumpclient} }
} }
} }
} }
define-command grep-next-match -docstring 'Jump to the next grep match' %{ define-command grep-next-match -docstring 'Jump to the next grep match' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
# First jump to enf of buffer so that if grep_current_line == 0 # First jump to enf of buffer so that if grep_current_line == 0
# 0g<a-l> will be a no-op and we'll jump to the first result. # 0g<a-l> will be a no-op and we'll jump to the first result.
# Yeah, thats ugly... # Yeah, thats ugly...
exec "ge %opt{grep_current_line}g<a-l> /^[^:]+:\d+:<ret>" execute-keys "ge %opt{grep_current_line}g<a-l> /^[^:]+:\d+:<ret>"
grep-jump grep-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec gg %opt{grep_current_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys gg %opt{grep_current_line}g } }
} }
define-command grep-previous-match -docstring 'Jump to the previous grep match' %{ define-command grep-previous-match -docstring 'Jump to the previous grep match' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
# See comment in grep-next-match # See comment in grep-next-match
exec "ge %opt{grep_current_line}g<a-h> <a-/>^[^:]+:\d+:<ret>" execute-keys "ge %opt{grep_current_line}g<a-h> <a-/>^[^:]+:\d+:<ret>"
grep-jump grep-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec gg %opt{grep_current_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys gg %opt{grep_current_line}g } }
} }

View File

@ -29,8 +29,9 @@ add-highlighter shared/ regions -default code kakrc \
keywords="edit write write-all kill quit write-quit write-all-quit map unmap alias unalias keywords="edit write write-all kill quit write-quit write-all-quit map unmap alias unalias
buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter
hook remove-hooks define-command echo debug source try fail hook remove-hooks define-command echo debug source try fail
set-option unset-option update-option declare-option exec eval prompt menu on-key info set-option unset-option update-option declare-option execute-keys evaluate-commands
set-face rename-client set-register select change-directory rename-session colorscheme" prompt menu on-key info set-face rename-client set-register select change-directory
rename-session colorscheme"
attributes="global buffer window current attributes="global buffer window current
normal insert menu prompt goto view user object normal insert menu prompt goto view user object
number_lines show_matching show_whitespaces fill regex dynregex group flag_lines number_lines show_matching show_whitespaces fill regex dynregex group flag_lines
@ -64,15 +65,15 @@ add-highlighter shared/kakrc/shell ref sh
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden kak-indent-on-new-line %{ define-command -hidden kak-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with %[\W\S] # indent after line ending with %[\W\S]
try %{ exec -draft k <a-x> <a-k> \%[\W\S]$ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> \%[\W\S]$ <ret> j <a-gt> }
} }
} }
@ -84,7 +85,7 @@ hook -group kak-highlight global WinSetOption filetype=kak %{ add-highlighter wi
hook global WinSetOption filetype=kak %{ hook global WinSetOption filetype=kak %{
hook window InsertChar \n -group kak-indent kak-indent-on-new-line hook window InsertChar \n -group kak-indent kak-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group kak-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group kak-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
set-option buffer extra_word_chars '-' set-option buffer extra_word_chars '-'
} }

View File

@ -15,7 +15,7 @@ All the optional arguments are forwarded to the make utility} \
mkfifo ${output} mkfifo ${output}
( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
printf %s\\n "eval -try-client '$kak_opt_toolsclient' %{ printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
edit! -fifo ${output} -scroll *make* edit! -fifo ${output} -scroll *make*
set-option buffer filetype make set-option buffer filetype make
set-option buffer make_current_error_line 0 set-option buffer make_current_error_line 0
@ -47,35 +47,35 @@ declare-option -docstring "name of the client in which all source code jumps wil
str jumpclient str jumpclient
define-command -hidden make-jump %{ define-command -hidden make-jump %{
eval -collapse-jumps %{ evaluate-commands -collapse-jumps %{
try %{ try %{
exec gl<a-?> "Entering directory" <ret><a-:> execute-keys gl<a-?> "Entering directory" <ret><a-:>
# Try to parse the error into capture groups, failing on absolute paths # Try to parse the error into capture groups, failing on absolute paths
exec s "Entering directory '([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l execute-keys s "Entering directory '([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
set-option buffer make_current_error_line %val{cursor_line} set-option buffer make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -markup %{{Information}%reg{5}}; try %{ focus }" evaluate-commands -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -markup %{{Information}%reg{5}}; try %{ focus }"
} catch %{ } catch %{
exec <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l execute-keys <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
set-option buffer make_current_error_line %val{cursor_line} set-option buffer make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -markup %{{Information}%reg{4}}; try %{ focus }" evaluate-commands -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -markup %{{Information}%reg{4}}; try %{ focus }"
} }
} }
} }
define-command make-next-error -docstring 'Jump to the next make error' %{ define-command make-next-error -docstring 'Jump to the next make error' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>" execute-keys "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>"
make-jump make-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec %opt{make_current_error_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } }
} }
define-command make-previous-error -docstring 'Jump to the previous make error' %{ define-command make-previous-error -docstring 'Jump to the previous make error' %{
eval -collapse-jumps -try-client %opt{jumpclient} %{ evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{make_current_error_line}g" "<a-/>^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>" execute-keys "%opt{make_current_error_line}g" "<a-/>^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}<ret>"
make-jump make-jump
} }
try %{ eval -client %opt{toolsclient} %{ exec %opt{make_current_error_line}g } } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } }
} }

View File

@ -10,10 +10,10 @@ hook global BufCreate .*/?[mM]akefile %{
add-highlighter shared/ regions -default content makefile \ add-highlighter shared/ regions -default content makefile \
comment '#' '$' '' \ comment '#' '$' '' \
eval '\$\(' '\)' '\(' evaluate-commands '\$\(' '\)' '\('
add-highlighter shared/makefile/comment fill comment add-highlighter shared/makefile/comment fill comment
add-highlighter shared/makefile/eval fill value add-highlighter shared/makefile/evaluate-commands fill value
add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable
add-highlighter shared/makefile/content regex [+?:]= 0:operator add-highlighter shared/makefile/content regex [+?:]= 0:operator
@ -35,15 +35,15 @@ add-highlighter shared/makefile/content regex [+?:]= 0:operator
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden makefile-indent-on-new-line %{ define-command -hidden makefile-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
## If the line above is a target indent with a tab ## If the line above is a target indent with a tab
try %{ exec -draft Z k<a-x> <a-k>^[^:]+:\s<ret> z i<tab> } try %{ execute-keys -draft Z k<a-x> <a-k>^[^:]+:\s<ret> z i<tab> }
# cleanup trailing white space son previous line # cleanup trailing white space son previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# indent after some keywords # indent after some keywords
try %{ exec -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b<ret> z <a-gt> } try %{ execute-keys -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b<ret> z <a-gt> }
} }
} }

View File

@ -37,7 +37,7 @@ define-command -hidden -params 1..2 man-impl %{ %sh{
if [ "${retval}" -eq 0 ]; then if [ "${retval}" -eq 0 ]; then
printf %s\\n " printf %s\\n "
edit -scratch '*man*' edit -scratch '*man*'
exec '%|cat<space>${colout}<ret>gk' execute-keys '%|cat<space>${colout}<ret>gk'
nop %sh{rm ${colout}} nop %sh{rm ${colout}}
set-option buffer filetype man set-option buffer filetype man
set-option window manpage '$@' set-option window manpage '$@'
@ -75,5 +75,5 @@ The page can be a word, or a word directly followed by a section number between
;; ;;
esac esac
printf %s\\n "eval -collapse-jumps -try-client %opt{docsclient} man-impl $pagenum $subject" printf %s\\n "evaluate-commands -collapse-jumps -try-client %opt{docsclient} man-impl $pagenum $subject"
} } } }

View File

@ -64,15 +64,15 @@ add-highlighter shared/python/comment fill comment
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden python-indent-on-new-line %{ define-command -hidden python-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with : # indent after line ending with :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> :$ <ret> j <a-gt> }
} }
} }
@ -84,7 +84,7 @@ hook -group python-highlight global WinSetOption filetype=python %{ add-highligh
hook global WinSetOption filetype=python %{ hook global WinSetOption filetype=python %{
hook window InsertChar \n -group python-indent python-indent-on-new-line hook window InsertChar \n -group python-indent python-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group python-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group python-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
} }
hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python } hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python }

View File

@ -29,7 +29,7 @@ define-command autorestore-restore-buffer -docstring "Restore the backup for the
## Replace the content of the buffer with the content of the backup file ## Replace the content of the buffer with the content of the backup file
echo -debug Restoring file: ${newer} echo -debug Restoring file: ${newer}
exec -draft %{ %d!cat<space>\"${newer}\"<ret>d } execute-keys -draft %{ %d!cat<space>\"${newer}\"<ret>d }
## If the backup file has to be removed, issue the command once ## If the backup file has to be removed, issue the command once
## the current buffer has been saved ## the current buffer has been saved

View File

@ -26,33 +26,33 @@ add-highlighter shared/cabal/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:varia
define-command -hidden cabal-filter-around-selections %{ define-command -hidden cabal-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden cabal-indent-on-new-line %[ define-command -hidden cabal-indent-on-new-line %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %[ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ] try %[ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent # preserve previous line indent
try %[ exec -draft \; K <a-&> ] try %[ execute-keys -draft \; K <a-&> ]
# filter previous line # filter previous line
try %[ exec -draft k : cabal-filter-around-selections <ret> ] try %[ execute-keys -draft k : cabal-filter-around-selections <ret> ]
# indent after lines ending with { or : # indent after lines ending with { or :
try %[ exec -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ] try %[ execute-keys -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ]
] ]
] ]
define-command -hidden cabal-indent-on-opening-curly-brace %[ define-command -hidden cabal-indent-on-opening-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align indent with opening paren when { is entered on a new line after the closing paren # align indent with opening paren when { is entered on a new line after the closing paren
try %[ exec -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] try %[ execute-keys -draft h <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ]
] ]
] ]
define-command -hidden cabal-indent-on-closing-curly-brace %[ define-command -hidden cabal-indent-on-closing-curly-brace %[
eval -draft -itersel %[ evaluate-commands -draft -itersel %[
# align to opening curly brace when alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z<ret> 1<a-&> ] try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z<ret> 1<a-&> ]
] ]
] ]

View File

@ -14,13 +14,13 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX)
mkfifo ${dir}/fifo mkfifo ${dir}/fifo
printf %s\\n "set-option buffer clang_tmp_dir ${dir}" printf %s\\n "set-option buffer clang_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
# end the previous %sh{} so that its output gets interpreted by kakoune # end the previous %sh{} so that its output gets interpreted by kakoune
# before launching the following as a background task. # before launching the following as a background task.
%sh{ %sh{
dir=${kak_opt_clang_tmp_dir} dir=${kak_opt_clang_tmp_dir}
printf %s\\n "eval -draft %{ printf %s\\n "evaluate-commands -draft %{
edit! -fifo ${dir}/fifo -debug *clang-output* edit! -fifo ${dir}/fifo -debug *clang-output*
set-option buffer filetype make set-option buffer filetype make
set-option buffer make_current_error_line 0 set-option buffer make_current_error_line 0
@ -75,11 +75,11 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
print id "|" docstrings[id] "|" menu print id "|" docstrings[id] "|" menu
} }
}' | paste -s -d ':' - | sed -e "s/\\\\n/\\n/g; s/'/\\\\'/g") }' | paste -s -d ':' - | sed -e "s/\\\\n/\\n/g; s/'/\\\\'/g")
printf %s\\n "eval -client ${kak_client} echo 'clang completion done' printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang completion done'
set-option 'buffer=${kak_buffile}' clang_completions '${header}:${compl}'" | kak -p ${kak_session} set-option 'buffer=${kak_buffile}' clang_completions '${header}:${compl}'" | kak -p ${kak_session}
else else
clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr
printf %s\\n "eval -client ${kak_client} echo 'clang parsing done'" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang parsing done'" | kak -p ${kak_session}
fi fi
flags=$(cat ${dir}/stderr | sed -rne " flags=$(cat ${dir}/stderr | sed -rne "
@ -104,12 +104,12 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
define-command clang-complete -docstring "Complete the current selection" %{ clang-parse -complete } define-command clang-complete -docstring "Complete the current selection" %{ clang-parse -complete }
define-command -hidden clang-show-completion-info %[ try %[ define-command -hidden clang-show-completion-info %[ try %[
eval -draft %[ evaluate-commands -draft %[
exec <space>{( <a-k> ^\( <ret> b <a-k> \A\w+\z <ret> execute-keys <space>{( <a-k> ^\( <ret> b <a-k> \A\w+\z <ret>
%sh[ %sh[
desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }") desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }")
if [ -n "$desc" ]; then if [ -n "$desc" ]; then
printf %s\\n "eval -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}" printf %s\\n "evaluate-commands -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}"
fi fi
] ] ] ]
] ] ] ]
@ -118,7 +118,7 @@ define-command clang-enable-autocomplete -docstring "Enable automatic clang comp
set-option window completers "option=clang_completions:%opt{completers}" set-option window completers "option=clang_completions:%opt{completers}"
hook window -group clang-autocomplete InsertIdle .* %{ hook window -group clang-autocomplete InsertIdle .* %{
try %{ try %{
exec -draft <a-h><a-k>(\.|->|::).\z<ret> execute-keys -draft <a-h><a-k>(\.|->|::).\z<ret>
echo 'completing...' echo 'completing...'
clang-complete clang-complete
} }
@ -170,7 +170,7 @@ define-command clang-diagnostics-next -docstring "Jump to the next line that con
done done
line=${line-$first_line} line=${line-$first_line}
if [ -n "$line" ]; then if [ -n "$line" ]; then
printf %s\\n "exec ${line} g" printf %s\\n "execute-keys ${line} g"
else else
echo "echo -markup '{Error}no next clang diagnostic'" echo "echo -markup '{Error}no next clang diagnostic'"
fi fi

View File

@ -46,23 +46,23 @@ add-highlighter shared/coffee/code regex \b(break|case|catch|class|const|continu
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden coffee-filter-around-selections %{ define-command -hidden coffee-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
define-command -hidden coffee-indent-on-new-line %{ define-command -hidden coffee-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P } try %{ execute-keys -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : coffee-filter-around-selections <ret> } try %{ execute-keys -draft k : coffee-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ <ret> j <a-gt> }
} }
} }

View File

@ -58,19 +58,19 @@ add-highlighter shared/cucumber/code regex \b(Feature|Business\h+Need|Ability|Ba
define-command -hidden cucumber-filter-around-selections %{ define-command -hidden cucumber-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden cucumber-indent-on-new-line %{ define-command -hidden cucumber-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : cucumber-filter-around-selections <ret> } try %{ execute-keys -draft k : cucumber-filter-around-selections <ret> }
# indent after lines containing : # indent after lines containing :
try %{ exec -draft <space> k x <a-k> : <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> : <ret> j <a-gt> }
} }
} }

View File

@ -41,7 +41,7 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file
} }
hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{ hook buffer BufWritePre %val{buffile} -group editorconfig-hooks %{ %sh{
if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then if [ ${kak_opt_editorconfig_trim_trailing_whitespace} = "true" ]; then
printf %s\\n "try %{ exec -draft %{ %s\h+$<ret>d } }" printf %s\\n "try %{ execute-keys -draft %{ %s\h+$<ret>d } }"
fi fi
} } } }
} }

View File

@ -44,21 +44,21 @@ add-highlighter shared/elixir/code regex '\b\d+[\d_]*\b' 0:value
define-command -hidden elixir-filter-around-selections %{ define-command -hidden elixir-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden elixir-indent-on-new-line %{ define-command -hidden elixir-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# indent after line ending with: # indent after line ending with:
# try %{ exec -draft k x <a-k> (do|else|->)$ <ret> & } # try %{ execute-keys -draft k x <a-k> (do|else|->)$ <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : elixir-filter-around-selections <ret> } try %{ execute-keys -draft k : elixir-filter-around-selections <ret> }
# indent after lines ending with do or -> # indent after lines ending with do or ->
try %{ exec -draft \\; k x <a-k> ^.+(do|->)$ <ret> j <a-gt> } try %{ execute-keys -draft \\; k x <a-k> ^.+(do|->)$ <ret> j <a-gt> }
} }
} }

View File

@ -31,23 +31,23 @@ add-highlighter shared/elm/code regex \b(Array|Bool|Char|Float|Int|String)\b 0:t
define-command -hidden elm-filter-around-selections %{ define-command -hidden elm-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden elm-indent-after " define-command -hidden elm-indent-after "
exec -draft \\; k x <a-k> ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ <ret> j <a-gt> execute-keys -draft \\; k x <a-k> ^\\h*(if)|(case\\h+[\\w']+\\h+of|let|in|\\{\\h+\\w+|\\w+\\h+->|[=(])$ <ret> j <a-gt>
" "
define-command -hidden elm-indent-on-new-line %{ define-command -hidden elm-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comments prefix and following white spaces # copy -- comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# align to first clause # align to first clause
try %{ exec -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* <ret> s \A|.\z <ret> & } try %{ execute-keys -draft \; k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* <ret> s \A|.\z <ret> & }
# filter previous line # filter previous line
try %{ exec -draft k : elm-filter-around-selections <ret> } try %{ execute-keys -draft k : elm-filter-around-selections <ret> }
# indent after lines beginning with condition or ending with expression or =( # indent after lines beginning with condition or ending with expression or =(
try %{ elm-indent-after } try %{ elm-indent-after }
} }

View File

@ -43,7 +43,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
mkfifo ${output} mkfifo ${output}
( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & ( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null &
printf %s "eval -try-client '$kak_opt_docsclient' %{ printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{
edit! -fifo ${output} *git* edit! -fifo ${output} *git*
set-option buffer filetype '${filetype}' set-option buffer filetype '${filetype}'
hook -group fifo buffer BufCloseFifo .* %{ hook -group fifo buffer BufCloseFifo .* %{
@ -55,7 +55,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
run_git_blame() { run_git_blame() {
( (
printf %s "eval -client '$kak_client' %{ printf %s "evaluate-commands -client '$kak_client' %{
try %{ add-highlighter window flag_lines GitBlame git_blame_flags } try %{ add-highlighter window flag_lines GitBlame git_blame_flags }
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp' set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
@ -130,9 +130,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n
printf %s "edit '$msgfile' printf %s "edit '$msgfile'
hook buffer BufWritePost '.*\Q$msgfile\E' %{ %sh{ hook buffer BufWritePost '.*\Q$msgfile\E' %{ %sh{
if git commit -F '$msgfile' --cleanup=strip $@ > /dev/null; then if git commit -F '$msgfile' --cleanup=strip $@ > /dev/null; then
printf %s 'eval -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer' printf %s 'evaluate-commands -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer'
else else
printf %s 'eval -client $kak_client echo -markup %{{Error}Commit failed}' printf %s 'evaluate-commands -client $kak_client echo -markup %{{Error}Commit failed}'
fi fi
} }" } }"
} }

View File

@ -23,7 +23,7 @@ define-command go-complete -docstring "Complete the current selection with gocod
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set-option buffer go_complete_tmp_dir ${dir}" printf %s\\n "set-option buffer go_complete_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_complete_tmp_dir} dir=${kak_opt_go_complete_tmp_dir}
@ -34,7 +34,7 @@ define-command go-complete -docstring "Complete the current selection with gocod
header="${kak_cursor_line}.$((${kak_cursor_column} - $column_offset))@${kak_timestamp}" header="${kak_cursor_line}.$((${kak_cursor_column} - $column_offset))@${kak_timestamp}"
compl=$(echo "${gocode_data}" | sed 1d | awk -F ",," '{print $2 "||" $1}' | paste -s -d: -) compl=$(echo "${gocode_data}" | sed 1d | awk -F ",," '{print $2 "||" $1}' | paste -s -d: -)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
set-option buffer=${kak_bufname} gocode_completions '${header}:${compl}' set-option buffer=${kak_bufname} gocode_completions '${header}:${compl}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
@ -44,7 +44,7 @@ define-command go-complete -docstring "Complete the current selection with gocod
define-command go-enable-autocomplete -docstring "Add gocode completion candidates to the completer" %{ define-command go-enable-autocomplete -docstring "Add gocode completion candidates to the completer" %{
set-option window completers "option=gocode_completions:%opt{completers}" set-option window completers "option=gocode_completions:%opt{completers}"
hook window -group go-autocomplete InsertIdle .* %{ try %{ hook window -group go-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>[\w\.].\z<ret> execute-keys -draft <a-h><a-k>[\w\.].\z<ret>
go-complete go-complete
} } } }
alias window complete go-complete alias window complete go-complete
@ -66,7 +66,7 @@ define-command -params ..1 go-format \
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set-option buffer go_format_tmp_dir ${dir}" printf %s\\n "set-option buffer go_format_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_format_tmp_dir} dir=${kak_opt_go_format_tmp_dir}
@ -97,7 +97,7 @@ define-command -hidden -params 1..2 gogetdoc-cmd %{
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX)
printf %s\\n "set-option buffer go_doc_tmp_dir ${dir}" printf %s\\n "set-option buffer go_doc_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_go_doc_tmp_dir} dir=${kak_opt_go_doc_tmp_dir}
@ -119,12 +119,12 @@ define-command -hidden -params 1..2 gogetdoc-cmd %{
case "$1" in case "$1" in
"info") "info")
if [ ${status} -eq 0 ]; then if [ ${status} -eq 0 ]; then
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
info -anchor ${kak_cursor_line}.${kak_cursor_column} %@${output}@ info -anchor ${kak_cursor_line}.${kak_cursor_column} %@${output}@
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
else else
msg=$(printf %s "${output}" | cut -d' ' -f2-) msg=$(printf %s "${output}" | cut -d' ' -f2-)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo '${msg}' echo '${msg}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
@ -132,7 +132,7 @@ define-command -hidden -params 1..2 gogetdoc-cmd %{
"echo") "echo")
if [ ${status} -eq 0 ]; then if [ ${status} -eq 0 ]; then
signature=$(printf %s "${output}" | sed -n 3p) signature=$(printf %s "${output}" | sed -n 3p)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo '${signature}' echo '${signature}'
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
@ -143,14 +143,14 @@ define-command -hidden -params 1..2 gogetdoc-cmd %{
file=$(printf %s "${pos}" | cut -d: -f1) file=$(printf %s "${pos}" | cut -d: -f1)
line=$(printf %s "${pos}" | cut -d: -f2) line=$(printf %s "${pos}" | cut -d: -f2)
col=$(printf %s "${pos}" | cut -d: -f3) col=$(printf %s "${pos}" | cut -d: -f3)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
eval -try-client '${kak_opt_jumpclient}' edit -existing ${file} ${line} ${col} evaluate-commands -try-client '${kak_opt_jumpclient}' edit -existing ${file} ${line} ${col}
try %{ focus '${kak_opt_jumpclient}' } try %{ focus '${kak_opt_jumpclient}' }
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
fi fi
;; ;;
*) *)
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
echo -error %{unkown command '$1'} echo -error %{unkown command '$1'}
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
;; ;;

View File

@ -35,19 +35,19 @@ add-highlighter shared/haml/code regex ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z
define-command -hidden haml-filter-around-selections %{ define-command -hidden haml-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden haml-indent-on-new-line %{ define-command -hidden haml-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : haml-filter-around-selections <ret> } try %{ execute-keys -draft k : haml-filter-around-selections <ret> }
# indent after lines beginning with : or - # indent after lines beginning with : or -
try %{ exec -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
} }
} }

View File

@ -36,19 +36,19 @@ add-highlighter shared/hbs/block-expression regex ((\w|-)+)=(('|").*?('|")) 1:at
define-command -hidden hbs-filter-around-selections %{ define-command -hidden hbs-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden hbs-indent-on-new-line %{ define-command -hidden hbs-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y j p } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y j p }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : hbs-filter-around-selections <ret> } try %{ execute-keys -draft k : hbs-filter-around-selections <ret> }
# indent after lines beginning with : or - # indent after lines beginning with : or -
try %{ exec -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^\h*[:-] <ret> j <a-gt> }
} }
} }

View File

@ -8,11 +8,11 @@ define-command jedi-complete -docstring "Complete the current selection" %{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX)
mkfifo ${dir}/fifo mkfifo ${dir}/fifo
printf %s\\n "set-option buffer jedi_tmp_dir ${dir}" printf %s\\n "set-option buffer jedi_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks write ${dir}/buf" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf"
} }
%sh{ %sh{
dir=${kak_opt_jedi_tmp_dir} dir=${kak_opt_jedi_tmp_dir}
printf %s\\n "eval -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }" printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }"
( (
cd $(dirname ${kak_buffile}) cd $(dirname ${kak_buffile})
header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}"
@ -24,7 +24,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{
print(':'.join([(str(c.name).replace("|", "\\|") + "|" + str(c.docstring()).replace("|", "\\|")).replace(":", "\\:") + "|" + str(c.name).replace("|", "\\|") for c in script.completions()]).replace("'", r"\\\\'")) print(':'.join([(str(c.name).replace("|", "\\|") + "|" + str(c.docstring()).replace("|", "\\|")).replace(":", "\\:") + "|" + str(c.name).replace("|", "\\|") for c in script.completions()]).replace("'", r"\\\\'"))
END END
) )
printf %s\\n "eval -client ${kak_client} 'echo completed; set-option %{buffer=${kak_buffile}} jedi_completions \'${header}:${compl}\''" | kak -p ${kak_session} printf %s\\n "evaluate-commands -client ${kak_client} 'echo completed; set-option %{buffer=${kak_buffile}} jedi_completions \'${header}:${compl}\''" | kak -p ${kak_session}
rm -r ${dir} rm -r ${dir}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
} }
@ -33,7 +33,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{
define-command jedi-enable-autocomplete -docstring "Add jedi completion candidates to the completer" %{ define-command jedi-enable-autocomplete -docstring "Add jedi completion candidates to the completer" %{
set-option window completers "option=jedi_completions:%opt{completers}" set-option window completers "option=jedi_completions:%opt{completers}"
hook window -group jedi-autocomplete InsertIdle .* %{ try %{ hook window -group jedi-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>\..\z<ret> execute-keys -draft <a-h><a-k>\..\z<ret>
echo 'completing...' echo 'completing...'
jedi-complete jedi-complete
} } } }

View File

@ -94,9 +94,9 @@ define-command -hidden modeline-parse-impl %{
# [text]{white}{vi:|vim:|ex:}[white]{options} # [text]{white}{vi:|vim:|ex:}[white]{options}
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text] # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{
try %{ eval -draft %{ try %{ evaluate-commands -draft %{
exec \%s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \ execute-keys \%s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \
s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x> s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x>
eval -draft -itersel modeline-parse-impl evaluate-commands -draft -itersel modeline-parse-impl
} } } }
} }

View File

@ -56,36 +56,36 @@ define-command moon-alternative-file -docstring 'Jump to the alternate file (imp
}} }}
define-command -hidden moon-filter-around-selections %{ define-command -hidden moon-filter-around-selections %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
exec <a-x> execute-keys <a-x>
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft s \h + $ <ret> d } try %{ execute-keys -draft s \h + $ <ret> d }
} }
} }
define-command -hidden moon-indent-on-char %{ define-command -hidden moon-indent-on-char %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# align _else_ statements to start # align _else_ statements to start
try %{ exec -draft <a-x> <a-k> ^ \h * (else(if)?) $ <ret> <a-\;> <a-?> ^ \h * (if|unless|when) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (else(if)?) $ <ret> <a-\;> <a-?> ^ \h * (if|unless|when) <ret> s \A | \z <ret> \' <a-&> }
# align _when_ to _switch_ then indent # align _when_ to _switch_ then indent
try %{ exec -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (switch) <ret> s \A | \z <ret> \' <a-&> \' <space> <gt> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (when) $ <ret> <a-\;> <a-?> ^ \h * (switch) <ret> s \A | \z <ret> \' <a-&> \' <space> <gt> }
# align _catch_ and _finally_ to _try_ # align _catch_ and _finally_ to _try_
try %{ exec -draft <a-x> <a-k> ^ \h * (catch|finally) $ <ret> <a-\;> <a-?> ^ \h * (try) <ret> s \A | \z <ret> \' <a-&> } try %{ execute-keys -draft <a-x> <a-k> ^ \h * (catch|finally) $ <ret> <a-\;> <a-?> ^ \h * (try) <ret> s \A | \z <ret> \' <a-&> }
} }
} }
define-command -hidden moon-indent-on-new-line %{ define-command -hidden moon-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy -- comment prefix and following white spaces # copy -- comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^ \h * \K -- \h * <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^ \h * \K -- \h * <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : moon-filter-around-selections <ret> } try %{ execute-keys -draft k : moon-filter-around-selections <ret> }
# indent after start structure # indent after start structure
try %{ exec -draft k <a-x> <a-k> ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ <ret> j <a-gt> }
# deindent after return statements # deindent after return statements
try %{ exec -draft k <a-x> <a-k> ^ \h * (break|return) \b <ret> j <a-lt> } try %{ execute-keys -draft k <a-x> <a-k> ^ \h * (break|return) \b <ret> j <a-lt> }
} }
} }

View File

@ -34,26 +34,26 @@ add-highlighter shared/php/code regex \b(__halt_compiler|abstract|and|array|as|b
define-command -hidden php-filter-around-selections %{ define-command -hidden php-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden php-indent-on-char %< define-command -hidden php-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ exec -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
define-command -hidden php-indent-on-new-line %< define-command -hidden php-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces # copy // comments prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : php-filter-around-selections <ret> } try %{ execute-keys -draft k : php-filter-around-selections <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ exec -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
> >
> >

View File

@ -65,17 +65,17 @@ add-highlighter shared/pony/comment fill comment
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden pony-indent-on-new-line %{ define-command -hidden pony-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft <space> K <a-&> } try %{ execute-keys -draft <space> K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# copy '//' comment prefix and following white spaces # copy '//' comment prefix and following white spaces
# try %{ exec -draft k x s ^\h*//\h* <ret> y jgh P } # try %{ execute-keys -draft k x s ^\h*//\h* <ret> y jgh P }
# indent after line ending with : # indent after line ending with :
try %{ exec -draft <space> k x <a-k> (do|try|then|else|:|=>)$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k x <a-k> (do|try|then|else|:|=>)$ <ret> j <a-gt> }
# else, end are always de-indented # else, end are always de-indented
try %{ exec -draft <space> k x <a-k> (else|end):$ <ret> k x s ^\h* <ret> y j x <a-k> ^<c-r>" <ret> J <a-lt> } try %{ execute-keys -draft <space> k x <a-k> (else|end):$ <ret> k x s ^\h* <ret> y j x <a-k> ^<c-r>" <ret> J <a-lt> }
} }
} }
@ -87,7 +87,7 @@ hook -group pony-highlight global WinSetOption filetype=pony %{ add-highlighter
hook global WinSetOption filetype=pony %{ hook global WinSetOption filetype=pony %{
hook window InsertChar \n -group pony-indent pony-indent-on-new-line hook window InsertChar \n -group pony-indent pony-indent-on-new-line
# cleanup trailing whitespaces on current line insert end # cleanup trailing whitespaces on current line insert end
hook window InsertEnd .* -group pony-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } } hook window InsertEnd .* -group pony-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
} }
hook global WinSetOption filetype=pony %{ hook global WinSetOption filetype=pony %{

View File

@ -46,19 +46,19 @@ add-highlighter shared/pug/code regex ((?:\.[A-Za-z][A-Za-z0-9_-]*
define-command -hidden pug-filter-around-selections %{ define-command -hidden pug-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden pug-indent-on-new-line %{ define-command -hidden pug-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : pug-filter-around-selections <ret> } try %{ execute-keys -draft k : pug-filter-around-selections <ret> }
# copy '//', '|', '-' or '(!)=' prefix and following whitespace # copy '//', '|', '-' or '(!)=' prefix and following whitespace
try %{ exec -draft k <a-x> s ^\h*\K[/|!=-]{1,2}\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K[/|!=-]{1,2}\h* <ret> y gh j P }
# indent unless we copied something above # indent unless we copied something above
try %{ exec -draft <a-gt> <space> b s \S <ret> g l <a-lt> } try %{ execute-keys -draft <a-gt> <space> b s \S <ret> g l <a-lt> }
} }
} }

View File

@ -5,7 +5,7 @@ define-command racer-complete -docstring "Complete the current selection with ra
%sh{ %sh{
dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX)
printf %s\\n "set-option buffer racer_tmp_dir ${dir}" printf %s\\n "set-option buffer racer_tmp_dir ${dir}"
printf %s\\n "eval -no-hooks %{ write ${dir}/buf }" printf %s\\n "evaluate-commands -no-hooks %{ write ${dir}/buf }"
} }
%sh{ %sh{
dir=${kak_opt_racer_tmp_dir} dir=${kak_opt_racer_tmp_dir}
@ -44,7 +44,7 @@ define-command racer-complete -docstring "Complete the current selection with ra
print candidate print candidate
}' }'
) )
printf %s\\n "eval -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
set-option buffer=${kak_bufname} racer_completions %@${compl}@ set-option buffer=${kak_bufname} racer_completions %@${compl}@
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
rm -r ${dir} rm -r ${dir}
@ -55,7 +55,7 @@ define-command racer-complete -docstring "Complete the current selection with ra
define-command racer-enable-autocomplete -docstring "Add racer completion candidates to the completer" %{ define-command racer-enable-autocomplete -docstring "Add racer completion candidates to the completer" %{
set-option window completers "option=racer_completions:%opt{completers}" set-option window completers "option=racer_completions:%opt{completers}"
hook window -group racer-autocomplete InsertIdle .* %{ try %{ hook window -group racer-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>([\w\.]|::).\z<ret> execute-keys -draft <a-h><a-k>([\w\.]|::).\z<ret>
racer-complete racer-complete
} } } }
alias window complete racer-complete alias window complete racer-complete

View File

@ -31,27 +31,27 @@ add-highlighter shared/ragel/code regex \b(action|alnum|alpha|any|ascii|case|cnt
define-command -hidden ragel-filter-around-selections %{ define-command -hidden ragel-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden ragel-indent-on-char %< define-command -hidden ragel-indent-on-char %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< exec -draft <a-h> <a-k> ^\h+[]})]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[]})]$ <ret> m s \A|.\z <ret> 1<a-&> >
try %< exec -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> >
> >
> >
define-command -hidden ragel-indent-on-new-line %< define-command -hidden ragel-indent-on-new-line %<
eval -draft -itersel %< evaluate-commands -draft -itersel %<
# copy _#_ comment prefix and following white spaces # copy _#_ comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : ragel-filter-around-selections <ret> } try %{ execute-keys -draft k : ragel-filter-around-selections <ret> }
# indent after lines ending with opener token # indent after lines ending with opener token
try %< exec -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> >
> >
> >

View File

@ -19,7 +19,7 @@ All the optional arguments are forwarded to the ranger utility} \
ranger $@ --cmd " \ ranger $@ --cmd " \
map <return> eval \ map <return> eval \
fm.execute_console('shell \ fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \ echo evaluate-commands -client $kak_client edit {file} | \
kak -p $kak_session; \ kak -p $kak_session; \
tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \ tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')" if fm.thisfile.is_file else fm.execute_console('move right=1')"
@ -28,7 +28,7 @@ All the optional arguments are forwarded to the ranger utility} \
ranger $@ --cmd "'"'" \ ranger $@ --cmd "'"'" \
map <return> eval \ map <return> eval \
fm.execute_console('shell \ fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \ echo evaluate-commands -client $kak_client edit {file} | \
kak -p $kak_session; \ kak -p $kak_session; \
xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \ xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 & if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 &

View File

@ -31,19 +31,19 @@ add-highlighter shared/sass/code regex !important 0:keyword
define-command -hidden sass-filter-around-selections %{ define-command -hidden sass-filter-around-selections %{
# remove trailing white spaces # remove trailing white spaces
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden sass-indent-on-new-line %{ define-command -hidden sass-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy '/' comment prefix and following white spaces # copy '/' comment prefix and following white spaces
try %{ exec -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P } try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \; K <a-&> } try %{ execute-keys -draft \; K <a-&> }
# filter previous line # filter previous line
try %{ exec -draft k : sass-filter-around-selections <ret> } try %{ execute-keys -draft k : sass-filter-around-selections <ret> }
# avoid indent after properties and comments # avoid indent after properties and comments
try %{ exec -draft k <a-x> <a-K> [:/] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-K> [:/] <ret> j <a-gt> }
} }
} }

View File

@ -23,13 +23,13 @@ add-highlighter shared/taskpaper regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) 0
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden taskpaper-indent-on-new-line %{ define-command -hidden taskpaper-indent-on-new-line %{
eval -draft -itersel %{ evaluate-commands -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ exec -draft \;K<a-&> } try %{ execute-keys -draft \;K<a-&> }
## If the line above is a project indent with a tab ## If the line above is a project indent with a tab
try %{ exec -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> } try %{ execute-keys -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> }
# cleanup trailing white spaces on previous line # cleanup trailing white spaces on previous line
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
} }
} }

View File

@ -1669,9 +1669,9 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
} }
const CommandDesc exec_string_cmd = { const CommandDesc exec_string_cmd = {
"execute-keys",
"exec", "exec",
nullptr, "execute-keys <switches> <keys>: execute given keys as if entered by user",
"exec <switches> <keys>: execute given keys as if entered by user",
context_wrap_params, context_wrap_params,
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},
@ -1694,9 +1694,9 @@ const CommandDesc exec_string_cmd = {
}; };
const CommandDesc eval_string_cmd = { const CommandDesc eval_string_cmd = {
"evaluate-commands",
"eval", "eval",
nullptr, "evaluate-commands <switches> <commands>...: execute commands as if entered by user",
"eval <switches> <commands>...: execute commands as if entered by user",
context_wrap_params, context_wrap_params,
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},