summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-04-10 21:39:24 +0100
committerMaxime Coste <mawww@kakoune.org>2017-04-10 21:39:24 +0100
commit112bd156e42d54d5c5e6300a9bf34e2c2e857ff1 (patch)
tree2fa3702f976b9371c144ee99e1f7a68e473dbf46 /src
parentc1c40a4b56ef62a960a193cce2324cd966a6b4f7 (diff)
parent6b8587000b99ff973ea38cb8aa713bfb2c7502d2 (diff)
Merge remote-tracking branch 'lenormf/fix-filter-backup-suffix'
Diffstat (limited to 'src')
-rw-r--r--src/main.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.cc b/src/main.cc
index d0ccdf58..b8f27622 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -643,7 +643,7 @@ int run_server(StringView session,
return 0;
}
-int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView> files, bool quiet)
+int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView> files, bool quiet, StringView suffix_backup)
{
StringRegistry string_registry;
GlobalScope global_scope;
@@ -690,7 +690,8 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
for (auto& file : files)
{
Buffer* buffer = open_file_buffer(file);
- write_buffer_to_file(*buffer, file + ".kak-bak");
+ if (not suffix_backup.empty())
+ write_buffer_to_file(*buffer, file + suffix_backup);
apply_to_buffer(*buffer);
write_buffer_to_file(*buffer, file);
buffer_manager.delete_buffer(*buffer);
@@ -797,6 +798,7 @@ int main(int argc, char* argv[])
{ "d", { false, "run as a headless session (requires -s)" } },
{ "p", { true, "just send stdin as commands to the given session" } },
{ "f", { true, "act as a filter, executing given keys on given files" } },
+ { "i", { true, "backup the files on which a filter is applied using the given suffix" } },
{ "q", { false, "in filter mode, be quiet about errors applying keys" } },
{ "ui", { true, "set the type of user interface to use (ncurses, dummy, or json)" } },
{ "l", { false, "list existing sessions" } },
@@ -880,7 +882,8 @@ int main(int argc, char* argv[])
files.emplace_back(parser[i]);
return run_filter(*keys, init_cmds, files,
- (bool)parser.get_switch("q"));
+ (bool)parser.get_switch("q"),
+ parser.get_switch("i").value_or(StringView{}));
}
Vector<StringView> files;