From fe70add4b764d7af7968498c4f5557d651119a42 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 25 May 2014 17:36:12 +0100 Subject: [PATCH] Disable 'interactive' options in :exec/:eval Incremental search, automatic info and completion are not needed in non interactive context. --- src/commands.cc | 16 ++++++++++++++++ src/option_manager.cc | 7 ++++++- src/option_manager.hh | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) 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);