From 286462a2f6f8823b06cf7bf8373069adc094e6b3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 28 Jun 2012 14:01:37 +0200 Subject: [PATCH] Add Context::option_manager() it returns the more specific option manager available (window -> buffer -> global) --- src/context.hh | 10 ++++++++++ src/main.cc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/context.hh b/src/context.hh index 86362467..3cfb979c 100644 --- a/src/context.hh +++ b/src/context.hh @@ -32,6 +32,16 @@ struct Context return *m_window; } bool has_window() const { return m_window; } + + OptionManager& option_manager() const + { + if (m_window) + return m_window->option_manager(); + if (m_buffer) + return m_buffer->option_manager(); + return GlobalOptionManager::instance(); + } + public: safe_ptr m_window; safe_ptr m_buffer; diff --git a/src/main.cc b/src/main.cc index c86c33a8..aa084566 100644 --- a/src/main.cc +++ b/src/main.cc @@ -440,7 +440,7 @@ int main(int argc, char* argv[]) { return context.window().selections_content().back(); }); shell_manager.register_env_var("opt_.+", [](const String& name, const Context& context) - { return context.window().option_manager()[name.substr(4)].as_string(); }); + { return context.option_manager()[name.substr(4)].as_string(); }); register_commands(); register_highlighters(); register_filters();