eval,exec: -restore-selections become -draft, and restore the buffer as well

This commit is contained in:
Maxime Coste 2013-03-22 13:42:29 +01:00
parent 38a46a6682
commit eeadb59f7f
4 changed files with 7 additions and 7 deletions

View File

@ -483,7 +483,7 @@ void declare_option(const CommandParameters& params, Context& context)
template<typename Func>
void context_wrap(const CommandParameters& params, Context& context, Func func)
{
ParametersParser parser(params, { { "client", true }, { "restore-selections", false }});
ParametersParser parser(params, { { "client", true }, { "draft", false }});
if (parser.positional_count() == 0)
throw wrong_argument_count();
@ -491,11 +491,11 @@ void context_wrap(const CommandParameters& params, Context& context, Func func)
ClientManager::instance().get_client_context(parser.option_value("client"))
: context;
if (parser.has_option("restore-selections"))
if (parser.has_option("draft"))
{
Editor& editor = real_context.editor();
DynamicSelectionList sels(editor.buffer(), editor.selections());
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
DynamicSelectionList sels{editor.buffer(), editor.selections()};
auto restore_sels = on_scope_end([&]{ editor.select(sels); real_context.change_editor(editor); });
func(parser, real_context);
}
else

View File

@ -29,7 +29,7 @@ def clang-complete %{
}
def clang-enable-autocomplete %{
hook window InsertIdle .* %{ eval -restore-selections %{
hook window InsertIdle .* %{ eval -draft %{
exec <a-h>
%sh{ [[ $kak_selection =~ .*(\.|->|::).$ ]] && echo "exec <a-space>; echo 'completing...'; clang-complete" }
}}

View File

@ -22,7 +22,7 @@ hook global WinSetOption filetype=cpp %~
addfilter -group cpp-filters regex ^(\h+)([^\n]*[^([{]\h*|$) \n \n$1
addfilter -group cpp-filters regex ^(\h*)[^\n]*[([{]\h* \n '\n$1 '
addfilter -group cpp-filters cleanup_whitespaces
hook window InsertEnd .* %{ exec -restore-selections <a-x>s\h+$<ret>d }
hook window InsertEnd .* %{ exec -draft <a-x>s\h+$<ret>d }
~
hook global WinSetOption filetype=(?!cpp).* %{

View File

@ -26,7 +26,7 @@ def -shell-params \
}}
def funcinfo %{
eval -restore-selections %{
eval -draft %{
exec [(<space>B;
%sh{
if [[ "$kak_selection" =~ [a-zA-Z_]+\( ]]; then