rust-selection-sort.kak/README.adoc

69 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-03-09 22:17:22 -05:00
= kakutils-rs
2022-01-22 18:25:22 -05:00
2022-03-09 22:17:22 -05:00
Sort by regular expression or lexicographically, find uniqes, shuffle, or evaluate rust selections without spawning a new command for each.
2022-01-23 21:34:13 -05:00
2022-03-09 22:21:24 -05:00
[![asciicast](https://asciinema.org/a/dIQh9NtLRkzVEENxmij5qBaai.svg)](https://asciinema.org/a/dIQh9NtLRkzVEENxmij5qBaai)
2022-01-23 21:34:13 -05:00
== Example
. Imagine you want to sort these stages
+
[source,groovy]
----
2022-03-09 22:21:24 -05:00
stage("Build") { # Step 1
8+3
2022-01-23 21:34:13 -05:00
}
2022-03-09 22:21:24 -05:00
stage("Compile") { # Step 5
math::log2(8)
2022-01-23 21:34:13 -05:00
}
2022-03-09 22:21:24 -05:00
stage("Assemble") { # Step 10
2^9+math::log2(10)
2022-01-23 21:34:13 -05:00
}
2022-03-09 22:21:24 -05:00
stage("Make") { # Step 100
not_a_formula
}
2022-01-23 21:34:13 -05:00
----
. Select the stage and stage body with: `%sstage<ret>MLM`
2022-03-09 22:17:22 -05:00
. Sort the selection by step number with: `:utils sort #\d+<ret>` (sort on whole capture) or `:utils sort "'.+?#(\d).+?'"` (sort on first capture group, which contains only the digits)
. Note if you just run `:utils sort<ret>`
2022-01-23 21:34:13 -05:00
2022-01-22 18:25:22 -05:00
== Configuration
2022-01-23 21:30:07 -05:00
[source,sh,title='sh']
----
2022-03-09 22:17:22 -05:00
cargo install --git https://github.com/austenadler/kakutils-rs
2022-01-23 21:30:07 -05:00
----
2022-01-22 18:25:22 -05:00
[source,title='kakrc']
----
2022-07-10 16:36:14 -04:00
define-command utils -params .. -shell-script-candidates %{
# use kak_token_to_complete;
kakutils-rs shell-script-candidates
} %{
2022-01-22 18:25:22 -05:00
eval -save-regs '"' %{
eval %sh{
2022-02-12 22:50:30 -05:00
# use kak_command_fifo kak_response_fifo;
2022-03-12 18:18:09 -05:00
kakutils-rs "$@"
2022-01-22 18:25:22 -05:00
}
}
}
----
2022-01-23 21:30:07 -05:00
== Usage
* Make multiple selections
2022-03-09 22:17:22 -05:00
* Run `utils sort` to sort the selections lexicographically
* Run `utils sort REGEX` to sort by regex match
2022-01-23 21:30:07 -05:00
** If the regex does not contain a capture group
** If the regex contains at least one capture group
== TODO
2022-03-09 22:17:22 -05:00
* I don't know what will happen with multiline strings and regex
2022-01-23 21:30:07 -05:00
* Figure out how to change the `no_skip_whitespace` option name in the source
2022-03-09 22:17:22 -05:00
* Get sort by selections working