First commit that works

This commit is contained in:
Austen Adler 2022-01-22 18:25:22 -05:00
parent 211c7b7e26
commit 20c43a5f6a
2 changed files with 24 additions and 2 deletions

18
README.adoc Normal file
View File

@ -0,0 +1,18 @@
= rust-selection-sort.kak
== Configuration
[source,title='kakrc']
----
define-command s -params 0..1 %{
eval -save-regs '"' %{
reg dquote %val{selections}
eval %sh{
regex="${1:-.*}"
eval set -- "$kak_quoted_selections"
~/syncthing/code/rust-selection-sort.kak/target/debug/rust-selection-sort "$regex" "$@" > "$kak_command_fifo"
}
exec R
}
}
----

View File

@ -4,7 +4,7 @@ use regex::Regex;
use std::env;
fn main() {
let args = env::args().collect::<Vec<String>>();
assert!(args.len() < 2, "Usage: rust-selection-sort REGEX SEL1 [SEL2 ...]");
assert!(args.len() > 2, "Usage: rust-selection-sort REGEX SEL1 [SEL2 ...]");
let replacement_re = &args[1];
@ -28,9 +28,13 @@ fn main() {
a.cmp(b)
});
print!("reg '\"'");
for i in &zipped {
print!("{}\0", i.0);
let new_selection = i.0.replace("'", "''");
print!(" '{}'", new_selection);
// print!("{}\0", new_selection);
// TODO: Allow debugging with -d
// println!("\n\tSort key: {:?}", i.1);
}
print!(" ;");
}