Support -buffer * to iterate over all buffers in :eval or :exec

This commit is contained in:
Maxime Coste 2015-04-21 13:40:14 +01:00
parent 1d40827da3
commit 4bb1e0a878

View File

@ -1160,9 +1160,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
ClientManager& cm = ClientManager::instance(); ClientManager& cm = ClientManager::instance();
if (auto bufnames = parser.get_switch("buffer")) if (auto bufnames = parser.get_switch("buffer"))
{ {
for (auto& name : split(*bufnames, ',')) auto context_wrap_for_buffer = [&](Buffer& buffer) {
{
Buffer& buffer = BufferManager::instance().get_buffer(name);
InputHandler input_handler{{ buffer, Selection{} }, InputHandler input_handler{{ buffer, Selection{} },
Context::Flags::Transient}; Context::Flags::Transient};
Context& c = input_handler.context(); 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); ScopedDisable keymaps_disable(c.keymaps_support(), disable_keymaps);
func(parser, c); 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; return;
} }