From 4bb1e0a8780afd93d5148e900ef1eb03a37789cd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 21 Apr 2015 13:40:14 +0100 Subject: [PATCH] Support -buffer * to iterate over all buffers in :eval or :exec --- src/commands.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 0d75d61f..8f6fff70 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1160,9 +1160,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) ClientManager& cm = ClientManager::instance(); if (auto bufnames = parser.get_switch("buffer")) { - for (auto& name : split(*bufnames, ',')) - { - Buffer& buffer = BufferManager::instance().get_buffer(name); + auto context_wrap_for_buffer = [&](Buffer& buffer) { InputHandler input_handler{{ buffer, Selection{} }, Context::Flags::Transient}; Context& c = input_handler.context(); @@ -1172,7 +1170,13 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) ScopedDisable keymaps_disable(c.keymaps_support(), disable_keymaps); func(parser, c); - } + }; + if (*bufnames == "*") + for (auto buffer : BufferManager::instance()) + context_wrap_for_buffer(*buffer); + else + for (auto& name : split(*bufnames, ',')) + context_wrap_for_buffer(BufferManager::instance().get_buffer(name)); return; }