diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-14 14:20:18 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-14 14:20:18 +0200 |
| commit | b630189ce52886d4284f800c46eee500a2ec0e6c (patch) | |
| tree | 36df8ca7b133636068b38e40d7d4aaa3d70eb48c /src | |
| parent | 4e34f777b0001afb995f1840e6f8c049fcb3d4b4 (diff) | |
Add a writeall (wa) command
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/commands.cc b/src/commands.cc index 1f2aa3d3..faf399c9 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -282,6 +282,21 @@ void write_buffer(const CommandParameters& params, Context& context) buffer.notify_saved(); } +void write_all_buffers(const CommandParameters& params, Context& context) +{ + if (params.size() != 0) + throw wrong_argument_count(); + + for (auto& buffer : BufferManager::instance()) + { + if (buffer->type() != Buffer::Type::Scratch and buffer->is_modified()) + { + write_buffer_to_file(*buffer, buffer->name()); + buffer->notify_saved(); + } + } +} + template<bool force> void quit(const CommandParameters& params, Context& context) { @@ -758,6 +773,7 @@ void register_commands() cm.register_commands({ "e", "edit" }, edit<false>, filename_completer); cm.register_commands({ "e!", "edit!" }, edit<true>, filename_completer); cm.register_commands({ "w", "write" }, write_buffer, filename_completer); + cm.register_commands({ "wa", "writeall" }, write_all_buffers); cm.register_commands({ "q", "quit" }, quit<false>); cm.register_commands({ "q!", "quit!" }, quit<true>); cm.register_command("wq", write_and_quit<false>); |
