1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 20:41:49 +03:00

Disable 'interactive' options in :exec/:eval

Incremental search, automatic info and completion are
not needed in non interactive context.
This commit is contained in:
Maxime Coste 2014-05-25 17:36:12 +01:00
parent f08966197e
commit fe70add4b7
3 changed files with 23 additions and 1 deletions

View File

@ -955,6 +955,22 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
GlobalHooks::instance().enable_hooks(); GlobalHooks::instance().enable_hooks();
}); });
struct DisableOption {
DisableOption(Context& context, const char* name)
: m_option(context.options()[name]),
m_prev_value(m_option.get<bool>())
{ 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(); ClientManager& cm = ClientManager::instance();
if (parser.has_option("buffer")) if (parser.has_option("buffer"))
{ {

View File

@ -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); auto it = find_option(m_options, name);
if (it != m_options.end()) if (it != m_options.end())
@ -67,6 +67,11 @@ const Option& OptionManager::operator[](const String& name) const
throw option_not_found(name); throw option_not_found(name);
} }
const Option& OptionManager::operator[](const String& name) const
{
return const_cast<OptionManager&>(*this)[name];
}
template<typename MatchingFunc> template<typename MatchingFunc>
CandidateList OptionManager::get_matching_names(MatchingFunc func) CandidateList OptionManager::get_matching_names(MatchingFunc func)
{ {

View File

@ -88,6 +88,7 @@ public:
OptionManager(OptionManager& parent); OptionManager(OptionManager& parent);
~OptionManager(); ~OptionManager();
Option& operator[] (const String& name);
const Option& operator[] (const String& name) const; const Option& operator[] (const String& name) const;
Option& get_local_option(const String& name); Option& get_local_option(const String& name);