eval,exec: -restore-selections become -draft, and restore the buffer as well
This commit is contained in:
parent
38a46a6682
commit
eeadb59f7f
|
@ -483,7 +483,7 @@ void declare_option(const CommandParameters& params, Context& context)
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
void context_wrap(const CommandParameters& params, Context& context, Func 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)
|
if (parser.positional_count() == 0)
|
||||||
throw wrong_argument_count();
|
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"))
|
ClientManager::instance().get_client_context(parser.option_value("client"))
|
||||||
: context;
|
: context;
|
||||||
|
|
||||||
if (parser.has_option("restore-selections"))
|
if (parser.has_option("draft"))
|
||||||
{
|
{
|
||||||
Editor& editor = real_context.editor();
|
Editor& editor = real_context.editor();
|
||||||
DynamicSelectionList sels(editor.buffer(), editor.selections());
|
DynamicSelectionList sels{editor.buffer(), editor.selections()};
|
||||||
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
|
auto restore_sels = on_scope_end([&]{ editor.select(sels); real_context.change_editor(editor); });
|
||||||
func(parser, real_context);
|
func(parser, real_context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,7 +29,7 @@ def clang-complete %{
|
||||||
}
|
}
|
||||||
|
|
||||||
def clang-enable-autocomplete %{
|
def clang-enable-autocomplete %{
|
||||||
hook window InsertIdle .* %{ eval -restore-selections %{
|
hook window InsertIdle .* %{ eval -draft %{
|
||||||
exec <a-h>
|
exec <a-h>
|
||||||
%sh{ [[ $kak_selection =~ .*(\.|->|::).$ ]] && echo "exec <a-space>; echo 'completing...'; clang-complete" }
|
%sh{ [[ $kak_selection =~ .*(\.|->|::).$ ]] && echo "exec <a-space>; echo 'completing...'; clang-complete" }
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -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 regex ^(\h*)[^\n]*[([{]\h* \n '\n$1 '
|
addfilter -group cpp-filters regex ^(\h*)[^\n]*[([{]\h* \n '\n$1 '
|
||||||
addfilter -group cpp-filters cleanup_whitespaces
|
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).* %{
|
hook global WinSetOption filetype=(?!cpp).* %{
|
||||||
|
|
|
@ -26,7 +26,7 @@ def -shell-params \
|
||||||
}}
|
}}
|
||||||
|
|
||||||
def funcinfo %{
|
def funcinfo %{
|
||||||
eval -restore-selections %{
|
eval -draft %{
|
||||||
exec [(<space>B;
|
exec [(<space>B;
|
||||||
%sh{
|
%sh{
|
||||||
if [[ "$kak_selection" =~ [a-zA-Z_]+\( ]]; then
|
if [[ "$kak_selection" =~ [a-zA-Z_]+\( ]]; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user