diff --git a/src/command_manager.cc b/src/command_manager.cc index 6a130ec7..470bd7cc 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -16,19 +16,19 @@ bool CommandManager::command_defined(const String& command_name) const return m_commands.find(command_name) != m_commands.end(); } -void CommandManager::register_command(const String& command_name, +void CommandManager::register_command(String command_name, Command command, - const CommandCompleter& completer) + CommandCompleter completer) { - m_commands[command_name] = CommandDescriptor { command, completer }; + m_commands[command_name] = { std::move(command), std::move(completer) }; } void CommandManager::register_commands(const memoryview& command_names, Command command, - const CommandCompleter& completer) + CommandCompleter completer) { for (auto command_name : command_names) - register_command(command_name, command, completer); + m_commands[command_name] = { command, completer }; } parse_error::parse_error(const String& error) diff --git a/src/command_manager.hh b/src/command_manager.hh index 07e7882b..f166f739 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -14,28 +14,25 @@ namespace Kakoune { -struct Context; - struct parse_error : runtime_error { parse_error(const String& error); }; +struct Context; using CommandParameters = memoryview; - -typedef std::function Command; - -typedef std::function CommandCompleter; +using Command = std::function; +using CommandCompleter = std::function; class PerArgumentCommandCompleter { public: - typedef std::function ArgumentCompleter; - typedef memoryview ArgumentCompleterList; + using ArgumentCompleter = std::function; + using ArgumentCompleterList = memoryview; PerArgumentCommandCompleter(const ArgumentCompleterList& completers) : m_completers(completers.begin(), completers.end()) {} @@ -61,13 +58,13 @@ public: bool command_defined(const String& command_name) const; - void register_command(const String& command_name, + void register_command(String command_name, Command command, - const CommandCompleter& completer = CommandCompleter()); + CommandCompleter completer = CommandCompleter()); void register_commands(const memoryview& command_names, Command command, - const CommandCompleter& completer = CommandCompleter()); + CommandCompleter completer = CommandCompleter()); private: void execute_single_command(const CommandParameters& params,