Write updated selections to fifo
This commit is contained in:
parent
731c97117f
commit
971a7b9ca6
@ -47,7 +47,8 @@ define-command sort-selections -params 0.. %{
|
||||
|
||||
# TODO: Send additional parameters
|
||||
|
||||
rust-selection-sort -R "$regex" $args -- "$@" > "$kak_command_fifo"
|
||||
rust-selection-sort -R "$regex" -f "$kak_command_fifo" -- "$@"
|
||||
|
||||
}
|
||||
exec R
|
||||
}
|
||||
|
13
src/main.rs
13
src/main.rs
@ -3,6 +3,8 @@
|
||||
use alphanumeric_sort::compare_str;
|
||||
use clap::Parser;
|
||||
use regex::Regex;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
struct KakMessage(String, Option<String>);
|
||||
@ -91,7 +93,12 @@ fn run() -> Result<(), KakMessage> {
|
||||
}
|
||||
});
|
||||
|
||||
print!("reg '\"'");
|
||||
let mut f = OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
.open(&options.fifo_name)?;
|
||||
|
||||
write!(f, "reg '\"'")?;
|
||||
|
||||
let iter: Box<dyn Iterator<Item = _>> = if options.reverse {
|
||||
Box::new(zipped.iter().rev())
|
||||
@ -101,9 +108,9 @@ fn run() -> Result<(), KakMessage> {
|
||||
|
||||
for i in iter {
|
||||
let new_selection = i.0.replace('\'', "''");
|
||||
print!(" '{}'", new_selection);
|
||||
write!(f, " '{}'", new_selection)?;
|
||||
}
|
||||
print!(" ;");
|
||||
write!(f, " ;")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user