mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-20 01:41:40 +03:00
f6a2925950
Level out the builtin commands loaded at startup in terms of format and expressiveness. The following convention was followed: * commands that take more than one argument have to be described along with their parameters prior to the actual documentation, otherwise the docstring consists in a capitalized sentence e.g. `command <arg1>: do something` * optional arguments are enclosed in square brackets, to comply with the format used for hardcoded commands e.g. `cd [<directory>]` * describe the effects of the command in the documentation string and omit implementation details unless they are relevant. Usually command names include the name of the tool they use, so they don't need to be redundantly mentioned e.g. `tmux-new-pane <arguments>: open a new pane` * document the format the parameters to the commands, or list them if they are to be chosen among a list of static values (c.f. `spell.kak`)
16 lines
621 B
Plaintext
16 lines
621 B
Plaintext
decl str formatcmd ""
|
|
def format -docstring "Format the contents of the current buffer" %{
|
|
%sh{
|
|
if [ ! -z "${kak_opt_formatcmd}" ]; then
|
|
readonly kak_opt_formatcmd=$(printf '%s' "${kak_opt_formatcmd}" | sed 's/ /<space>/g')
|
|
## Save the current position of the cursor
|
|
readonly x=$((kak_cursor_column - 1))
|
|
readonly y="${kak_cursor_line}"
|
|
|
|
printf %s\\n "exec -draft %{%|${kak_opt_formatcmd}<ret>}"
|
|
## Try to restore the position of the cursor as it was prior to formatting
|
|
printf %s\\n "exec gg ${y}g ${x}l"
|
|
fi
|
|
}
|
|
}
|