diff --git a/src/commands.cc b/src/commands.cc index 86a2cc4b..25c206f0 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -955,6 +955,22 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) GlobalHooks::instance().enable_hooks(); }); + struct DisableOption { + DisableOption(Context& context, const char* name) + : m_option(context.options()[name]), + m_prev_value(m_option.get()) + { m_option.set(false); } + + ~DisableOption() { m_option.set(m_prev_value); } + + Option& m_option; + bool m_prev_value; + }; + DisableOption disable_autoinfo(context, "autoinfo"); + DisableOption disable_autoshowcompl(context, "autoshowcompl"); + DisableOption disable_incsearch(context, "incsearch"); + + ClientManager& cm = ClientManager::instance(); if (parser.has_option("buffer")) { diff --git a/src/option_manager.cc b/src/option_manager.cc index f2c6576c..0bb2f4df 100644 --- a/src/option_manager.cc +++ b/src/option_manager.cc @@ -56,7 +56,7 @@ Option& OptionManager::get_local_option(const String& name) } -const Option& OptionManager::operator[](const String& name) const +Option& OptionManager::operator[](const String& name) { auto it = find_option(m_options, name); if (it != m_options.end()) @@ -67,6 +67,11 @@ const Option& OptionManager::operator[](const String& name) const throw option_not_found(name); } +const Option& OptionManager::operator[](const String& name) const +{ + return const_cast(*this)[name]; +} + template CandidateList OptionManager::get_matching_names(MatchingFunc func) { diff --git a/src/option_manager.hh b/src/option_manager.hh index 244e1555..92c3ac7b 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -88,6 +88,7 @@ public: OptionManager(OptionManager& parent); ~OptionManager(); + Option& operator[] (const String& name); const Option& operator[] (const String& name) const; Option& get_local_option(const String& name);